/* =========================================================
   BLI Designer Portal — Editorial Design System
   ========================================================= */

:root {
    /* Palette — soft warm neutrals with olive/sage accent (mirrors brand site) */
    --bg:            #faf8f4;        /* very soft off-white */
    --bg-soft:       #f4f1ea;        /* sidebar / muted surface */
    --surface:       #ffffff;
    --surface-2:     #f4f1eb;
    --surface-3:     #ebe6dc;

    --ink:           #1a1a1a;        /* near black, matches brand */
    --ink-2:         #3a3a37;
    --ink-3:         #5a5852;
    --muted:         #85817a;
    --muted-2:       #a49f96;

    --line:          #e9e4d9;
    --line-2:        #d4cebf;
    --line-strong:   #b6ad99;

    /* Refined olive/sage — brand feels, not military */
    --brand:         #4d5a3f;         /* olive */
    --brand-2:       #3d4a30;
    --brand-3:       #2c3624;
    --brand-soft:    #e5e9dc;

    --accent:        #6b7d55;         /* fresh sage */
    --accent-soft:   #eef2e2;
    --accent-deep:   #4d5c3d;

    --ink-btn:       #1a1a1a;         /* primary button (black) */
    --ink-btn-2:     #2b2b2a;

    --danger:        #a83c2a;
    --danger-soft:   #f4dcd6;
    --warning:       #a07520;
    --warning-soft:  #f6ead0;
    --info:          #4a6580;
    --info-soft:     #dde5ec;
    --success:       #4d6b3f;
    --success-soft:  #e2ead6;

    --radius:        12px;
    --radius-sm:     8px;
    --radius-xs:     4px;

    --shadow-xs:     0 1px 0 rgba(26, 26, 26, 0.03);
    --shadow-sm:     0 1px 2px rgba(26, 26, 26, 0.04);
    --shadow:        0 4px 12px rgba(26, 26, 26, 0.05), 0 1px 3px rgba(26, 26, 26, 0.04);
    --shadow-lg:     0 24px 48px rgba(26, 26, 26, 0.10), 0 4px 12px rgba(26, 26, 26, 0.05);

    /* Adaptive sidebar: narrower on smaller desktops, comfortable on large */
    --sidebar-w:     clamp(216px, 17vw, 260px);
    --content-max:   1240px;

    --font-display:  "Cardo", "Fraunces", Georgia, serif;
    --font-body:     "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono:     "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    --dur-fast:      120ms;
    --dur:           200ms;
    --ease:          cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
    font-size: 15.5px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 400;
    font-feature-settings: "ss01", "ss02", "cv11";
    line-height: 1.55;
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Type scale ---------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--ink);
    font-weight: 400;
    letter-spacing: -0.015em;
    line-height: 1.15;
    margin: 0 0 0.5rem;
}

h1 { font-size: clamp(1.75rem, 2.6vw, 2.4rem); font-weight: 380; letter-spacing: -0.025em; }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.05rem; font-family: var(--font-body); font-weight: 600; letter-spacing: -0.005em; }
h5 { font-size: 0.95rem; font-family: var(--font-body); font-weight: 600; }
h6 { font-size: 0.85rem; font-family: var(--font-body); font-weight: 600; }

p { margin-top: 0; }

a {
    color: var(--ink);
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--accent); }

hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 1.5rem 0;
    opacity: 1;
}

::selection {
    background: var(--accent-soft);
    color: var(--ink);
}

/* Small caps utility for editorial labels */
.eyebrow,
.overline {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---------- App shell ---------- */
.mobile-topbar { display: none; }

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 25, 23, 0.35);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
}
.sidebar-overlay.show { display: block; opacity: 1; }

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    background: var(--bg-soft);
    border-right: 1px solid var(--line);
    color: var(--ink-2);
    overflow: hidden;
}

/* Compact sidebar header — logo + brand on a single line */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.15rem 1.15rem 1.15rem;
    border-bottom: 1px solid var(--line);
}

.sidebar-header a.sidebar-mark {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: var(--ink);
    min-width: 0;
    flex: 1;
}

.sidebar-header .sidebar-mark-img {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(26, 26, 26, 0.06);
}

.sidebar-header .sidebar-mark-img img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: brightness(1.05);
}

.sidebar-header .sidebar-mark-text {
    min-width: 0;
    line-height: 1.1;
}

.sidebar-header .sidebar-mark-text strong {
    display: block;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.05rem;
    color: var(--ink);
    letter-spacing: -0.005em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-header .sidebar-mark-text span {
    display: block;
    margin-top: 0.15rem;
    font-family: var(--font-body);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Legacy classes retained for any templates still using them */
.sidebar-logo,
.sidebar-brand { display: none; }

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0.65rem 0.6rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.nav-section-label {
    margin: 1.05rem 0.75rem 0.35rem;
    padding: 0;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted-2);
}
.sidebar-nav > li:first-child .nav-section-label,
.sidebar-nav .nav-section-label:first-child { margin-top: 0.2rem; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1px;
    border-radius: 6px;
    color: var(--ink-2);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    letter-spacing: -0.005em;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
    position: relative;
    line-height: 1.2;
}

.sidebar-nav a i {
    width: 1.05rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--muted);
    transition: color var(--dur-fast) var(--ease);
    flex-shrink: 0;
}

.sidebar-nav a > span,
.sidebar-nav a {
    min-width: 0;
}

.sidebar-nav a:hover {
    background: rgba(26, 26, 26, 0.05);
    color: var(--ink);
}
.sidebar-nav a:hover i { color: var(--ink-2); }

.sidebar-nav a.active {
    background: var(--brand);
    color: #f7f5ee;
    font-weight: 500;
}
.sidebar-nav a.active i { color: #d8dfc6; }

.sidebar-footer {
    padding: 0.75rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    font-size: 0.72rem;
    color: var(--muted-2);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
}

/* Adaptive sidebar width for smaller desktops */
@media (min-width: 992px) and (max-width: 1200px) {
    :root { --sidebar-w: 220px; }
    .sidebar-header { padding: 1rem 0.9rem; gap: 0.6rem; }
    .sidebar-header .sidebar-mark-img { width: 30px; height: 30px; }
    .sidebar-header .sidebar-mark-img img { width: 22px; height: 22px; }
    .sidebar-header .sidebar-mark-text strong { font-size: 0.98rem; }
    .sidebar-nav a { font-size: 0.84rem; padding: 0.45rem 0.65rem; }
}

@media (min-width: 1600px) {
    :root { --sidebar-w: 260px; }
}

.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-w));
    padding: 2.75rem 2.75rem 3rem;
}

.main-content.is-auth {
    margin-left: 0;
    width: 100%;
    padding: 0;
}

.page-container {
    max-width: var(--content-max);
    margin: 0 auto;
}

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 2.25rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.page-header .page-title {
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-weight: 380;
    letter-spacing: -0.025em;
    color: var(--ink);
}

.page-header .page-title i {
    display: none;
}

.page-header .page-subtitle {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    max-width: 44rem;
    line-height: 1.5;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.card:hover {
    border-color: var(--line-2);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 1.15rem 1.5rem;
    background: transparent;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.card-header h4,
.card-header h5,
.card-header .card-title {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.005em;
}

.card-header h4 i,
.card-header h5 i,
.card-header .card-title i {
    color: var(--muted);
    margin-right: 0.5rem;
    font-size: 0.9em;
}

.card-header .card-subtitle {
    display: block;
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 400;
    letter-spacing: 0;
}

.card-body {
    padding: 1.5rem;
    background: var(--surface);
}

/* Brand header variant (olive) */
.card-header.card-header-brand {
    background: var(--brand);
    border-bottom: none;
    color: #fff;
}
.card-header.card-header-brand h4,
.card-header.card-header-brand h5,
.card-header.card-header-brand .card-title { color: #fff; }
.card-header.card-header-brand i { color: #d8dfc6; }

/* ---------- Stat cards (editorial) ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.stat-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.stat-card {
    background: var(--surface);
    padding: 1.5rem 1.65rem;
    position: relative;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid var(--line);
}

.stat-grid > .stat-card:last-child { border-right: none; }
.stat-card::before { display: none; }

.stat-card .stat-label {
    margin: 0 0 0.9rem;
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-card .stat-value {
    margin: 0;
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 380;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -0.03em;
    font-feature-settings: "lnum", "tnum";
}

.stat-card .stat-value .unit {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--muted);
    margin-left: 0.15rem;
    letter-spacing: 0;
}

.stat-card .stat-meta {
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

/* accent classes retained but very subtle */
.stat-card.accent-sage,
.stat-card.accent-blue,
.stat-card.accent-amber,
.stat-card.accent-rose,
.stat-card.accent-plum { /* handled globally */ }

.stat-value.text-danger { color: var(--danger) !important; }
.stat-value.text-success { color: var(--success) !important; }

/* ---------- Forms ---------- */
.form-label {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    color: var(--ink-2);
    margin-bottom: 0.4rem;
    text-transform: none;
}

.form-control,
.form-select {
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    font-size: 0.92rem;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--ink);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
    box-shadow: none;
}

.form-control:hover,
.form-select:hover { border-color: var(--line-strong); }

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(77, 90, 63, 0.16);
    outline: none;
    background: var(--surface);
}

.form-control::placeholder { color: var(--muted-2); }

.form-text,
small.text-muted { color: var(--muted) !important; }

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(77, 90, 63, 0.16); }

/* ---------- Tables ---------- */
.table {
    color: var(--ink);
    margin-bottom: 0;
    --bs-table-bg: transparent;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: transparent !important;
    color: var(--muted) !important;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line) !important;
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
    background: transparent;
    color: var(--ink);
}

.table tbody tr:last-child td { border-bottom: none; }

.table-hover tbody tr {
    transition: background var(--dur-fast) var(--ease);
}
.table-hover tbody tr:hover td { background: var(--surface-2); }

.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: var(--surface-2);
}

/* Cell emphasis */
.table td strong { font-weight: 600; color: var(--ink); }
.table td.num,
.table td .num,
.table td .money {
    font-family: var(--font-display);
    font-feature-settings: "lnum", "tnum";
    font-weight: 400;
    font-size: 1rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.88rem;
    letter-spacing: -0.005em;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.1rem;
    border: 1px solid transparent;
    box-shadow: none;
    line-height: 1.2;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn i {
    font-size: 0.95em;
    line-height: 1;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-xs);
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-primary:hover,
.btn-primary:focus {
    background: var(--brand-2);
    border-color: var(--brand-2);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--line-2);
    color: var(--ink);
}
.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--ink);
    color: var(--ink);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: #3d5a34;
    border-color: #3d5a34;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #8e3223;
    border-color: #8e3223;
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #fff;
}
.btn-warning:hover {
    background: #86611b;
    border-color: #86611b;
    color: #fff;
}

.btn-outline-primary {
    color: var(--brand);
    border-color: var(--line-2);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-outline-secondary {
    color: var(--ink-2);
    border-color: var(--line-2);
    background: transparent;
}
.btn-outline-secondary:hover {
    background: var(--surface-2);
    color: var(--ink);
    border-color: var(--line-strong);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: rgba(168, 60, 42, 0.35);
    background: transparent;
}
.btn-outline-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

/* Bootstrap group styling — respectful of design system */
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-top-left-radius: var(--radius-xs); border-bottom-left-radius: var(--radius-xs); }
.btn-group .btn:last-child  { border-top-right-radius: var(--radius-xs); border-bottom-right-radius: var(--radius-xs); }
.btn-group .btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: none;
}

/* ---------- Badges / alerts ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.32em 0.7em;
    border-radius: 999px;
    line-height: 1.3;
}

.bg-primary   { background-color: var(--brand) !important; color: #fff !important; }
.bg-success   { background-color: var(--success-soft) !important; color: var(--success) !important; }
.bg-danger    { background-color: var(--danger-soft) !important; color: var(--danger) !important; }
.bg-warning   { background-color: var(--warning-soft) !important; color: var(--warning) !important; }
.bg-info      { background-color: var(--info-soft) !important; color: var(--info) !important; }
.bg-secondary { background-color: var(--surface-3) !important; color: var(--ink-2) !important; }

/* Solid variants for badges that need contrast */
.badge.badge-solid.bg-success { background: var(--success) !important; color: #fff !important; }
.badge.badge-solid.bg-danger  { background: var(--danger) !important; color: #fff !important; }
.badge.badge-solid.bg-warning { background: var(--warning) !important; color: #fff !important; }

.alert {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.15rem;
    box-shadow: none;
    font-size: 0.9rem;
}

.alert-warning,
.active-entry {
    background: var(--warning-soft);
    border-color: rgba(160, 117, 32, 0.25);
    color: #5c4517;
}

.alert-danger,
.alert-error {
    background: var(--danger-soft);
    border-color: rgba(168, 60, 42, 0.25);
    color: #6a2418;
}

.alert-success {
    background: var(--success-soft);
    border-color: rgba(74, 106, 63, 0.25);
    color: #2c3f25;
}

.alert-info {
    background: var(--info-soft);
    border-color: rgba(74, 101, 128, 0.25);
    color: #2a3d4d;
}

.active-entry {
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-sm);
    padding: 1.15rem 1.25rem;
    margin: 0.5rem 0 1.25rem;
}

.upcoming-product {
    background: var(--info-soft);
    border-left: 3px solid var(--info);
}

.overdue-product {
    background: var(--danger-soft);
    border-left: 3px solid var(--danger);
}

/* ---------- Feed / list items ---------- */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.feed-item {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 1rem 0.25rem;
    transition: background var(--dur-fast) var(--ease);
}
.feed-item:last-child { border-bottom: none; padding-bottom: 0.25rem; }
.feed-item:first-child { padding-top: 0.25rem; }
.feed-item.is-urgent {
    background: transparent;
    border-color: var(--line);
    padding-left: 0.75rem;
    border-left: 2px solid var(--warning);
}

.feed-item-title {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--ink);
}

.feed-item-meta {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.5;
}
.feed-item-meta i {
    margin-right: 0.25rem;
    color: var(--muted-2);
}

/* ---------- Project list rows ---------- */
.project-row {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
    transition: border-color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease),
                background var(--dur) var(--ease);
}
.project-row:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow);
    color: inherit;
    background: var(--surface);
    transform: none;
}
.project-row-name {
    margin: 0 0 0.2rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: -0.015em;
    color: var(--ink);
}
.project-row-customer {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}
.project-row-address {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

/* ---------- Empty states ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: transparent;
    border-radius: var(--radius);
    border: 1px dashed var(--line-2);
}
.empty-state i {
    font-size: 2.5rem;
    color: var(--muted-2);
    display: block;
    margin-bottom: 0.75rem;
}
.empty-state p {
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}
.empty-state .btn { margin-top: 1.25rem; }

/* ---------- Modals ---------- */
.modal-content {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: var(--surface);
}

.modal-header {
    background: transparent;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.25rem 1.5rem;
}

.modal-header .modal-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.25rem;
    letter-spacing: -0.015em;
    color: var(--ink);
}

.modal-header .btn-close {
    filter: none;
    opacity: 0.5;
}

.modal-header.card-header-brand {
    background: var(--brand);
    color: #fff;
    border-bottom: none;
}
.modal-header.card-header-brand .modal-title { color: #fff; }
.modal-header.card-header-brand .btn-close { filter: invert(1) grayscale(1); opacity: 0.8; }

.modal-body { padding: 1.5rem; }
.modal-footer {
    border-top: 1px solid var(--line);
    padding: 1rem 1.5rem;
    gap: 0.5rem;
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(ellipse 900px 500px at 15% -10%, rgba(138, 106, 68, 0.12), transparent 60%),
        radial-gradient(ellipse 700px 400px at 100% 110%, rgba(26, 25, 23, 0.08), transparent 60%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-card-header {
    padding: 2.5rem 2rem 1.5rem;
    text-align: center;
    background: transparent;
    border-bottom: 1px solid var(--line);
}

.login-card-header .login-mark {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: var(--brand);
    margin: 0 auto 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 1px rgba(26, 26, 26, 0.06);
}
.login-card-header .login-mark img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin: 0;
    filter: brightness(1.05);
}

.login-card-header img.login-legacy {
    max-height: 40px;
    margin-bottom: 1.25rem;
}

.login-card-header h1 {
    margin: 0;
    font-size: 1.65rem;
    font-family: var(--font-display);
    font-weight: 380;
    letter-spacing: -0.025em;
    color: var(--ink);
}

.login-card-header p {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.login-card-body { padding: 2rem; }

.login-hint {
    margin-top: 1.5rem;
    padding: 0.9rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.5;
}
.login-hint code {
    background: var(--surface);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--ink);
    border: 1px solid var(--line);
}

/* ---------- Helpers ---------- */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
.content-grid > .card { margin-bottom: 0; height: 100%; }

.section-block { margin-bottom: 1.75rem; }

.mini-metric {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
}
.mini-metric .label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
}
.mini-metric .value {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--ink);
    letter-spacing: -0.015em;
    font-feature-settings: "lnum", "tnum";
}

.text-muted   { color: var(--muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }

.fw-semibold  { font-weight: 600 !important; }

/* Project-detail 5-column helper */
@media (min-width: 992px) {
    .col-md-2-4 { flex: 0 0 20%; max-width: 20%; }
}

/* ---------- Legacy `.project-card` used on project detail ---------- */
.project-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 1.5rem;
    background: var(--surface);
    overflow: hidden;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.project-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.project-card .card-header {
    background: transparent;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--line);
}
.project-card .card-header h4 {
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
}
.project-card .card-body { background: var(--surface); padding: 1.5rem; }

.section-header {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--ink);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    margin: 0 0 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--line);
}

/* ---------- Container reset ---------- */
.container,
.container-fluid {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

/* ---------- Mobile ---------- */

@media (max-width: 991px) {
    .col-md-2-4 { flex: 0 0 50%; max-width: 50%; }

    .stat-grid,
    .stat-grid-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        border-radius: var(--radius);
    }
    .stat-card { border-right: none; border-bottom: 1px solid var(--line); }
    .stat-card:nth-child(odd)  { border-right: 1px solid var(--line); }
    .stat-card:nth-last-child(-n+2) { border-bottom: none; }

    .content-grid { grid-template-columns: 1fr; }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        position: sticky;
        top: 0;
        z-index: 1030;
        min-height: 60px;
        padding: 0.75rem 1rem;
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
        background: rgba(245, 242, 236, 0.85);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--line);
    }
    .mobile-topbar .menu-btn {
        width: 42px;
        height: 42px;
        border: 1px solid var(--line-2);
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--ink);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        flex-shrink: 0;
    }
    .mobile-topbar .topbar-brand { min-width: 0; flex: 1; }
    .mobile-topbar .topbar-brand strong {
        display: block;
        font-family: var(--font-display);
        font-size: 1.05rem;
        font-weight: 400;
        color: var(--ink);
        line-height: 1.2;
        letter-spacing: -0.015em;
    }
    .mobile-topbar .topbar-brand span {
        display: block;
        font-size: 0.66rem;
        color: var(--muted);
        letter-spacing: 0.14em;
        text-transform: uppercase;
        font-weight: 600;
        margin-top: 0.1rem;
    }
    .mobile-menu-toggle { display: none; }

    .sidebar {
        width: min(86vw, 320px);
        transform: translateX(-105%);
        transition: transform 0.28s var(--ease);
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 40px 80px rgba(26, 25, 23, 0.2);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-nav a { min-height: 48px; padding: 0.8rem 0.95rem; font-size: 1rem; }
    .sidebar-nav a i { font-size: 1.15rem; }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem 1rem calc(2rem + env(safe-area-inset-bottom, 0px));
    }

    .page-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
        align-items: flex-start;
    }

    .card-header,
    .card-body { padding: 1.15rem 1.15rem; }

    .btn { min-height: 44px; padding: 0.7rem 1rem; font-size: 0.95rem; }
    .btn-sm { min-height: 38px; padding: 0.5rem 0.85rem; font-size: 0.85rem; }

    .form-control,
    .form-select {
        min-height: 46px;
        font-size: 16px;
        padding: 0.7rem 0.85rem;
    }
    textarea.form-control { min-height: 110px; }

    .table-responsive { margin: 0 -0.25rem; }
    .table thead th,
    .table tbody td { padding: 0.85rem 0.75rem; font-size: 0.9rem; white-space: nowrap; }
    .table td.num,
    .table td .num,
    .table td .money { font-size: 0.95rem; }

    .modal-dialog { margin: 0.5rem; max-width: calc(100% - 1rem); }
    .modal-content { border-radius: var(--radius); }
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    .modal-footer .btn { width: 100%; margin: 0; }

    .project-row { padding: 1.1rem 1.15rem; }
    .project-row .text-md-end { text-align: left !important; }

    .stat-card { padding: 1.15rem 1.25rem; min-height: 108px; }
    .stat-card .stat-value { font-size: 1.7rem; }
}

@media (max-width: 576px) {
    html { font-size: 16px; }

    .stat-grid,
    .stat-grid-5 { grid-template-columns: 1fr 1fr; }
    .stat-card:nth-child(odd)  { border-right: 1px solid var(--line); }
    .stat-card { border-bottom: 1px solid var(--line); }
    .stat-card:nth-last-child(-n+2):not(:nth-last-child(2))  { border-bottom: none; }

    .col-md-2-4 { flex: 0 0 50%; max-width: 50%; }

    h1, .page-title { font-size: 1.7rem; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.9rem;
    }
    .page-subtitle { font-size: 0.9rem; }

    .page-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .page-actions .btn { width: 100%; }

    .card { margin-bottom: 1rem; border-radius: var(--radius); }

    .login-page { padding: 1rem; align-items: stretch; place-items: stretch; }
    .login-card { margin: auto 0; border-radius: var(--radius); }
    .login-card-header,
    .login-card-body { padding: 1.75rem 1.35rem; }

    .btn-group {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 0.4rem;
    }
    .btn-group .btn {
        flex: 1 1 calc(50% - 0.2rem);
        border-radius: var(--radius-xs) !important;
    }

    td .d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }
    td .d-flex .btn { width: 100%; }

    .stat-card .stat-value { font-size: 1.5rem; }
    .stat-card { min-height: 100px; padding: 1.1rem 1.15rem; }
}

@media (max-width: 380px) {
    .stat-grid,
    .stat-grid-5,
    .col-md-2-4 { grid-template-columns: 1fr; flex: 0 0 100%; max-width: 100%; }
    .stat-card { border-right: none !important; border-bottom: 1px solid var(--line); }
    .stat-card:last-child { border-bottom: none; }
}

img, svg, video { max-width: 100%; height: auto; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
