/* ==========================================================================
   TEXFLOW ERP — App shell: sidebar, topbar, page frame
   ========================================================================== */

/* ---------- Shell ---------- */

.app {
    min-height: 100vh;
}

.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content {
    flex: 1;
    padding: 20px 24px 48px;
    max-width: 1720px;
    width: 100%;
}

/* ---------- Sidebar ---------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--navy);
    color: var(--on-dark);
    display: flex;
    flex-direction: column;
    z-index: 60;
    border-right: 1px solid #0B1220;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 16px;
    flex: none;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-mark {
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: var(--r);
    background: linear-gradient(140deg, #3B82F6, #1D4ED8);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -.03em;
}

.brand-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .02em;
    color: #fff;
    line-height: 1.1;
}

.brand-sub {
    display: block;
    font-size: 10px;
    color: var(--on-dark-muted);
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* Scrolling nav region */
.nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb {
    background: #26344a;
    border-radius: 8px;
    border: 2px solid var(--navy);
}

.nav-group { padding: 2px 0 6px; }

.nav-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 4px;
    padding: 0 16px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #64748B;
}
.nav-label svg {
    width: 13px;
    height: 13px;
    flex: none;
    stroke: #64748B;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-i {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 16px 6px 37px;
    font-size: 13px;
    color: #CBD5E1;
    border-left: 2px solid transparent;
    position: relative;
}
.nav-i:hover {
    background: rgba(148, 163, 184, .10);
    color: #fff;
}
.nav-i.is-active {
    background: rgba(37, 99, 235, .18);
    border-left-color: var(--blue);
    color: #fff;
    font-weight: 600;
}

.nav-count {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--r-pill);
    background: rgba(148, 163, 184, .18);
    color: #CBD5E1;
    font-variant-numeric: tabular-nums;
}
.nav-count.is-alert { background: rgba(220, 38, 38, .22); color: #FCA5A5; }

.sidebar-foot {
    flex: none;
    border-top: 1px solid rgba(255, 255, 255, .07);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-foot .factory-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #22C55E; flex: none;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
}
.sidebar-foot .f-name { font-size: 12px; color: #E2E8F0; }
.sidebar-foot .f-sub  { font-size: 10px; color: #64748B; }

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 0 20px;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 340px;
    max-width: 42vw;
    height: 34px;
    padding: 0 10px;
    background: var(--surface-sunken);
    border: 1px solid transparent;
    border-radius: var(--r);
    color: var(--muted);
}
.topbar-search:focus-within {
    background: #fff;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.topbar-search svg {
    width: 15px;
    height: 15px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
}
.topbar-search input {
    border: 0;
    background: none;
    outline: none;
    width: 100%;
    font-size: 13px;
}
.topbar-search kbd {
    font-family: var(--font);
    font-size: 10px;
    color: var(--muted-2);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: var(--r-sm);
    padding: 0 4px;
    background: #fff;
}

.topbar-spacer { flex: 1; min-width: 0; }

.icon-btn {
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--r);
    border: 1px solid transparent;
    background: none;
    color: var(--muted);
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .dot {
    position: absolute;
    top: 6px; right: 7px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid #fff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 8px 4px 4px;
    border-radius: var(--r);
    color: var(--text);
}
.topbar-user:hover { background: var(--surface-sunken); color: var(--text); }
.topbar-user .u-name { font-size: 13px; font-weight: 600; line-height: 1.15; }
.topbar-user .u-role { font-size: 11px; color: var(--muted); line-height: 1.15; }

.avatar {
    width: 30px; height: 30px;
    flex: none;
    border-radius: 50%;
    background: var(--navy-600);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.blue   { background: var(--blue); }
.avatar.green  { background: var(--green); }
.avatar.amber  { background: var(--amber); }
.avatar.purple { background: var(--purple); }

/* Mobile nav trigger — hidden on desktop */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-burger { display: none; }
.nav-scrim { display: none; }

/* ---------- Breadcrumb + page header ---------- */

.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--blue); text-decoration: underline; }
.crumbs .sep { color: var(--border-strong); }
.crumbs .current { color: var(--text-2); font-weight: 500; }

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.page-title h1 { font-size: 20px; }
.page-sub {
    margin-top: 3px;
    font-size: 13px;
    color: var(--muted);
}
.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin-top: 10px;
}
.page-meta .m-k {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted-2);
}
.page-meta .m-v { font-size: 13px; font-weight: 600; }

/* ---------- Content grids ---------- */

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.split      { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
.split-wide { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; }
.split-2-1  { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }

.stack   { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 10px; }
.row     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
