:root {
    --ink: #171411;
    --ink-soft: #665f57;
    --paper: #f7f4ef;
    --panel: #fffdfa;
    --line: #ded8cf;
    --brand: #d55831;
    --brand-dark: #ad3e20;
    --brand-soft: #fbe6dc;
    --success: #26785a;
    --success-soft: #e4f4ed;
    --warning: #9b650c;
    --warning-soft: #fff3d7;
    --danger: #a33b36;
    --danger-soft: #fbe8e6;
    --shadow: 0 18px 55px rgba(53, 39, 24, .09);
    --radius: 18px;
}

.orders-filters { display:grid; grid-template-columns: 2fr 1.2fr 1fr 1fr auto auto; gap:12px; align-items:end; margin-bottom:16px; }
.orders-table { min-width:950px; font-size:.86rem; }
.orders-table td { vertical-align:top; }
.orders-table td:nth-child(3) { min-width:230px; }
.orders-table td:nth-child(3) > div { margin-bottom:5px; }
.order-link { font-size:1.05rem; font-weight:800; text-decoration:none; }
.orders-pagination { display:flex; justify-content:space-between; gap:15px; margin-top:20px; }
.order-item { display:grid; grid-template-columns:48px 1fr auto; align-items:start; gap:12px; padding:18px 0; border-bottom:1px solid var(--line); }
.order-item small { display:block; }
.quantity-badge { display:grid; place-items:center; min-height:42px; border-radius:9px; background:var(--brand-soft); color:var(--brand-dark); font-weight:900; font-size:1.2rem; }
.order-detail-grid { margin-top:0; }
.order-detail-grid .field-help { margin-top:15px; }
.order-detail-grid .health-row { grid-template-columns:1fr auto; font-size:.85rem; }
.preserve-lines { white-space:pre-wrap; overflow-wrap:anywhere; }
.confirmation-panel { max-width:700px; }
.checkbox-label { display:flex; gap:10px; align-items:flex-start; }
.checkbox-label input { width:20px; min-height:20px; flex-shrink:0; }
@media(max-width:1200px) { .orders-filters { grid-template-columns:1fr 1fr; } }
@media(max-width:520px) { .orders-filters { grid-template-columns:1fr; } .order-item { grid-template-columns:42px 1fr; } .order-item > strong { grid-column:2; } }

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); }

button,
input,
select,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

h1,
h2,
h3,
p { margin-top: 0; }

h1 { margin-bottom: 0; font-size: clamp(1.4rem, 2.2vw, 2rem); line-height: 1.15; }
h2 { margin-bottom: .55rem; font-size: clamp(1.45rem, 2.5vw, 2.15rem); line-height: 1.15; letter-spacing: -.025em; }
h3 { margin-bottom: .45rem; font-size: 1.18rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    min-height: 100vh;
    height: 100vh;
    flex-direction: column;
    padding: 28px 22px 22px;
    color: #fff;
    background: #1c1916;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 14px 14px 14px 4px;
    color: #fff;
    background: var(--brand);
    font: 700 23px/1 Georgia, serif;
    box-shadow: 0 9px 24px rgba(213, 88, 49, .25);
}

.brand strong,
.brand small { display: block; }
.brand strong { font-size: 1.06rem; letter-spacing: .02em; }
.brand small { color: #aaa39b; font-size: .73rem; letter-spacing: .16em; text-transform: uppercase; }

.nav { display: grid; gap: 5px; margin-top: 46px; }
.nav a { padding: 11px 13px; border-radius: 10px; color: #d9d4ce; text-decoration: none; transition: .15s ease; }
.nav a:hover { color: #fff; background: #2c2824; }
.nav a.active { color: #fff; background: var(--brand); }
.nav-heading { margin: 20px 12px 5px; color: #7f7972; font-size: .68rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }

.sidebar-footer { display: grid; gap: 14px; margin-top: auto; padding-top: 24px; border-top: 1px solid #35312d; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip strong,
.user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: #9f9891; font-size: .78rem; }
.avatar { display: grid; flex: 0 0 34px; height: 34px; place-items: center; border-radius: 50%; color: #5d321f; background: #f5d6c7; font-weight: 800; }

.link-button { padding: 0; border: 0; color: var(--brand-dark); background: none; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.sidebar .link-button { color: #c5beb7; text-decoration: none; }

.main { min-width: 0; }
.topbar { display: flex; min-height: 114px; align-items: center; gap: 18px; padding: 24px clamp(22px, 4vw, 58px); border-bottom: 1px solid var(--line); background: rgba(247, 244, 239, .93); }
.topbar > div { flex: 1; }
.content { width: min(1220px, 100%); padding: 34px clamp(22px, 4vw, 58px) 60px; }
.eyebrow,
.kicker { display: block; margin-bottom: 7px; color: var(--brand); font-size: .69rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.phase-badge,
.health-pill { display: inline-flex; align-items: center; width: fit-content; padding: 5px 10px; border-radius: 999px; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.phase-badge { color: #6b3d29; background: var(--brand-soft); }
.muted-badge { color: #6f675f; background: #eee9e3; }
.health-pill.healthy { color: #185b43; background: var(--success-soft); }
.health-pill.error { color: #87302d; background: var(--danger-soft); }
.health-pill.neutral { color: #5f5953; background: #ece8e2; }

.menu-toggle { display: none; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }

.hero-panel,
.panel,
.metric-card,
.installer-card,
.auth-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 8px 28px rgba(53, 39, 24, .035);
}

.hero-panel { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: clamp(25px, 4vw, 44px); background: linear-gradient(135deg, #fffdfa, #f9eee6); }
.hero-panel p { max-width: 650px; margin-bottom: 0; color: var(--ink-soft); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.metric-card { position: relative; padding: 21px; }
.metric-card .status-dot { position: absolute; top: 22px; right: 20px; }
.metric-card small,
.metric-card strong { display: block; }
.metric-card small { margin-bottom: 7px; color: var(--ink-soft); }
.metric-card strong { font-size: 1.15rem; }
.metric-card p { margin: 7px 0 0; color: var(--ink-soft); font-size: .83rem; }

.panel { margin-top: 18px; padding: clamp(22px, 3vw, 32px); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.panel-heading h2,
.panel-heading h3 { margin-bottom: 0; }
.compact-panel { align-self: start; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 18px; }
.split-layout > .panel { margin-top: 0; }
.users-layout { grid-template-columns: minmax(0, 1.65fr) minmax(320px, .8fr); }

.workflow-preview { display: flex; align-items: center; gap: 12px; overflow-x: auto; color: var(--ink-soft); }
.workflow-preview span { flex: 0 0 auto; padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.workflow-preview b { color: #c4b9ae; }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.link-button:focus-visible { outline: 3px solid rgba(213, 88, 49, .25); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--brand); }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.button-block { width: 100%; }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }

.stacked-form { display: grid; gap: 17px; }
.stacked-form fieldset { display: grid; gap: 16px; margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: 13px; }
.stacked-form legend { padding: 0 8px; font-weight: 800; }
label { display: grid; gap: 7px; color: #38332e; font-size: .86rem; font-weight: 700; }
input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #cfc7bd;
    border-radius: 9px;
    color: var(--ink);
    background: #fff;
}
input::placeholder { color: #aaa29a; }
.form-grid { display: grid; gap: 15px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 78px; }
.password-field button { position: absolute; top: 50%; right: 6px; padding: 6px 8px; border: 0; color: var(--brand-dark); background: transparent; transform: translateY(-50%); cursor: pointer; font-size: .78rem; font-weight: 750; }
.field-help { margin: -6px 0 0; color: var(--ink-soft); font-size: .78rem; }
.inline-form { display: flex; align-items: center; gap: 14px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.inline-form small { color: var(--ink-soft); }

.notice { margin: 0 0 18px; padding: 13px 15px; border: 1px solid; border-radius: 10px; font-size: .88rem; }
.notice ul { margin-bottom: 0; }
.notice-success { color: #1c6148; border-color: #b9ddce; background: var(--success-soft); }
.notice-warning { color: #74500f; border-color: #ead19a; background: var(--warning-soft); }
.notice-error { color: #81332f; border-color: #e9bbb7; background: var(--danger-soft); }
.notice-info { color: #315f7c; border-color: #bcd5e5; background: #eaf4fa; }

.status-dot { display: inline-block; flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: #aaa; box-shadow: 0 0 0 4px rgba(120, 120, 120, .08); }
.status-dot.ok { background: var(--success); box-shadow: 0 0 0 4px rgba(38, 120, 90, .1); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 4px rgba(163, 59, 54, .1); }
.health-list { display: grid; }
.health-row { display: grid; grid-template-columns: 18px minmax(180px, 1fr) auto; align-items: center; gap: 10px; padding: 13px 3px; border-bottom: 1px solid #ebe6df; }
.health-row:last-child { border-bottom: 0; }
.health-row span:last-child { color: var(--ink-soft); }
.requirements { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 24px 0; }
.requirement { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #e7e1d9; border-radius: 9px; background: #fff; }
.requirement strong,
.requirement small { display: block; }
.requirement strong { font-size: .82rem; }
.requirement small { color: var(--ink-soft); font-size: .74rem; }

.definition-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.definition-grid > div { padding: 15px; border-radius: 11px; background: #f5f1eb; }
.definition-grid small,
.definition-grid strong { display: block; }
.definition-grid small { margin-bottom: 5px; color: var(--ink-soft); }
.check-list { margin: 18px 0 0; padding: 0; list-style: none; }
.check-list li { position: relative; padding: 9px 0 9px 27px; border-bottom: 1px solid #ebe6df; }
.check-list li::before { position: absolute; left: 2px; color: var(--success); content: "✓"; font-weight: 900; }
.check-list li:last-child { border-bottom: 0; }
.empty-state { margin-bottom: 0; padding: 26px; border: 1px dashed #cdc4b9; border-radius: 12px; color: var(--ink-soft); text-align: center; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th,
td { padding: 13px 10px; border-bottom: 1px solid #e8e2da; text-align: left; vertical-align: middle; }
th { color: var(--ink-soft); font-size: .73rem; letter-spacing: .08em; text-transform: uppercase; }
td small { display: block; color: var(--ink-soft); }

.minimal-page { min-height: 100vh; background: radial-gradient(circle at 15% 10%, #f9ded0 0, transparent 28%), var(--paper); }
.minimal-shell { width: min(800px, calc(100% - 32px)); margin: 0 auto; padding: 46px 0 36px; }
.brand-centered { display: flex; width: fit-content; margin: 0 auto 28px; color: var(--ink); }
.auth-card { width: min(440px, 100%); margin: 0 auto; padding: clamp(25px, 5vw, 42px); box-shadow: var(--shadow); }
.installer-card { padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow); }
.installer-heading { max-width: 620px; }
.installer-heading p,
.muted { color: var(--ink-soft); }
.minimal-shell footer { margin-top: 25px; color: #837a71; font-size: .75rem; text-align: center; }
code { padding: 2px 5px; border-radius: 5px; background: #eee8e1; font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

@media (max-width: 980px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-layout,
    .users-layout { grid-template-columns: 1fr; }
    .definition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(285px, 88vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0, 0, 0, .22); }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .topbar { min-height: 92px; padding: 18px; }
    .content { padding: 22px 16px 44px; }
    .hero-panel { align-items: flex-start; flex-direction: column; }
    .form-grid.two,
    .requirements { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .metric-grid,
    .definition-grid { grid-template-columns: 1fr; }
    .health-row { grid-template-columns: 18px 1fr; }
    .health-row span:last-child { grid-column: 2; }
    .inline-form { align-items: flex-start; flex-direction: column; }
    .phase-badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
