:root {
    --ink: #111827;
    --muted: #64748b;
    --line: #e5e7eb;
    --panel: #ffffff;
    --bg: #f6f7fb;
    --accent: #0f766e;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
a { color: var(--accent); }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #101828 0%, #164e63 55%, #f8fafc 55%);
    padding: 24px;
}
.auth-shell { width: min(100%, 440px); }
.login-card {
    background: #fff;
    border: 1px solid rgba(255,255,255,.6);
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 20px 70px rgba(15,23,42,.24);
}
.login-card h1 { font-size: 1.8rem; font-weight: 800; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 150px;
    background: #111827;
    color: #fff;
    padding: 14px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width .2s ease, left .2s ease;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 800; margin-bottom: 18px; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #14b8a6;
    color: #062a27;
    font-weight: 900;
}
.sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 8px;
    padding: 8px 9px;
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 3px;
    font-size: .8rem;
}
.sidebar .nav-link i { font-size: .95rem; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-heading { color: #94a3b8; font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; margin: 12px 9px 6px; }
body.sidebar-collapsed .sidebar { width: 56px; padding: 14px 8px; }
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-heading { display: none; }
body.sidebar-collapsed .brand,
body.sidebar-collapsed .sidebar .nav-link { justify-content: center; }
body.sidebar-collapsed .sidebar-collapse { padding-inline: 0; }

.main-panel { flex: 1; min-width: 0; }
.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    background: rgba(255,255,255,.9);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(14px);
}
.content { padding: 24px; }
.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}
.page-title h1 { font-size: 1.45rem; font-weight: 800; margin: 0; }
.page-title p { color: var(--muted); font-size: .88rem; margin: 3px 0 0; }

.panel, .metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(15,23,42,.04);
}
.panel.narrow { max-width: 920px; }
.panel h2 { font-size: .98rem; font-weight: 800; margin-bottom: 12px; }
.metric span { display: block; color: var(--muted); font-size: .85rem; }
.metric strong { display: block; font-size: 1.65rem; margin-top: 6px; }

.table { font-size: .82rem; }
.table th { color: #475569; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.table td { vertical-align: middle; }
.table > :not(caption) > * > * { padding: .45rem .58rem; }
.order-table .status-form { min-width: 150px; }
.actions-nowrap { white-space: nowrap; }
.order-thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.priority-high td { color: #dc2626; }
.priority-label {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 999px;
    color: #fff;
    background: #dc2626;
    font-size: .68rem;
    font-weight: 800;
}
.status-tabs { overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; }
.status-tabs .nav-link { white-space: nowrap; }
.btn { border-radius: 8px; font-size: .86rem; }
.form-label { font-size: .8rem; color: #475569; font-weight: 700; }
.form-control, .form-select { border-radius: 8px; font-size: .86rem; }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 8px; vertical-align: -2px; border: 1px solid var(--line); }
.filter-panel { padding: 14px; }
.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.filter-panel-header h2 { margin-bottom: 0; }
.filter-toggle {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
}
.filter-form { display: grid; gap: 14px; }
.filter-row {
    display: grid;
    gap: 12px;
    align-items: end;
}
.filter-row.first-row { grid-template-columns: repeat(6, minmax(140px, 1fr)); }
.filter-row.second-row { grid-template-columns: repeat(4, minmax(160px, 1fr)) minmax(120px, .7fr); }
.filter-row.inquiry-filter-row { grid-template-columns: repeat(6, minmax(140px, 1fr)) minmax(120px, .7fr); }
.filter-action { display: grid; }

.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.preview-grid.large { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.preview-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f8fafc;
}
.image-tile { position: relative; min-width: 0; }
.image-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(220, 38, 38, .95);
    color: #fff;
}
.notes-table td:last-child { min-width: 260px; overflow-wrap: anywhere; }
.history-table th,
.history-table td { white-space: nowrap; }
.compact-status-form { max-width: 180px; }
.order-entry .row.g-3 > [class*="col-"] {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}
.order-entry .form-label { margin-bottom: 0; font-weight: 700; }
.order-entry textarea.form-control { min-height: 88px; }
.order-entry .preview-grid { grid-column: 2; }
.gallery-thumb {
    border: 0;
    padding: 0;
    background: transparent;
    border-radius: 8px;
}
.gallery-thumb img { display: block; }
.gallery-full {
    display: block;
    width: 100%;
    max-height: 78vh;
    object-fit: contain;
}
.detail-list { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: .9rem; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.note-list { display: grid; gap: 10px; }
.note-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #f8fafc;
}
.note-item strong { display: block; font-weight: 700; overflow-wrap: anywhere; }
.note-item small { color: var(--muted); }
.tracking-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 12px;
    background: #f8fafc;
}

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: -170px;
        z-index: 20;
        transition: left .2s ease;
    }
    .sidebar.open { left: 0; }
    body.sidebar-collapsed .sidebar { width: 56px; }
    .content { padding: 18px; }
    .page-title { align-items: flex-start; flex-direction: column; }
    .topbar { padding: 0 18px; }
    .filter-row.first-row,
    .filter-row.second-row,
    .filter-row.inquiry-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-action { grid-column: 1 / -1; }
}

@media (max-width: 575px) {
    .login-card { padding: 24px; }
    .detail-list { grid-template-columns: 1fr; }
    .panel, .metric { padding: 16px; }
    .order-entry .row.g-3 > [class*="col-"] { grid-template-columns: 1fr; gap: 6px; }
    .filter-row.first-row,
    .filter-row.second-row,
    .filter-row.inquiry-filter-row { grid-template-columns: 1fr; }
}
