:root {
    --ink: #1f2833;
    --muted: #6b7380;
    --line: #e7e4df;
    --surface: #ffffff;
    --canvas: #f7f5f2;
    --brand: #6f4c72;
    --brand-dark: #56395a;
    --brand-soft: #eee7ef;
    --sage: #718478;
    --rose: #b5777f;
    --amber: #c29452;
    --danger: #a44646;
    --shadow: 0 16px 44px rgba(34, 29, 35, .07);
    --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 30px 22px 22px; background: #25212a; color: #fff; z-index: 20; }
.brand, .auth-brand { display: flex; align-items: center; gap: 13px; color: inherit; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(145deg, #be98bd, #80607f); color: #fff; font: 700 13px Georgia, serif; letter-spacing: .08em; box-shadow: inset 0 1px rgba(255,255,255,.3); }
.brand strong, .auth-brand strong { display: block; font-family: Georgia, serif; font-size: 18px; letter-spacing: .015em; }
.brand small, .auth-brand small, .user-chip small { display: block; margin-top: 2px; color: #aaa3ae; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 7px; margin-top: 48px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border-radius: 13px; color: #c9c4cc; font-size: 14px; font-weight: 600; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-link.active { color: #fff; background: rgba(190,152,189,.18); box-shadow: inset 3px 0 #be98bd; }
.nav-icon { width: 20px; height: 20px; border: 1.6px solid currentColor; border-radius: 6px; opacity: .85; }
.sidebar-foot { margin-top: auto; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.user-chip > span { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; background: var(--brand); }
.quiet-link { display: inline-block; margin: 15px 0 0 45px; color: #aaa3ae; font-size: 12px; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; min-height: 104px; padding: 24px clamp(24px, 4vw, 58px) 18px; }
.topbar h1 { margin: 3px 0 0; font: 500 clamp(26px, 3vw, 34px)/1.1 Georgia, serif; }
.eyebrow { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.content { padding: 0 clamp(24px, 4vw, 58px) 56px; }
.menu-button { display: none; }

.hero-panel { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; min-height: 210px; padding: clamp(30px, 4vw, 48px); margin-bottom: 24px; border-radius: 24px; background: linear-gradient(130deg, #49384c, #715874 65%, #92758f); color: #fff; box-shadow: var(--shadow); }
.hero-panel::after { content: ""; position: absolute; right: -100px; top: -150px; width: 380px; height: 380px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 55px rgba(255,255,255,.035), 0 0 0 110px rgba(255,255,255,.025); }
.hero-panel > * { position: relative; z-index: 1; }
.hero-panel .eyebrow { color: #d9c6d8; }
.hero-panel h2 { max-width: 620px; margin: 8px 0 12px; font: 500 clamp(30px, 4vw, 48px)/1.05 Georgia, serif; }
.hero-panel p { max-width: 590px; margin: 0; color: #dfd5df; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 24px 0; }
.stat-card { padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 7px 24px rgba(34,29,35,.035); }
.stat-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
.stat-card strong { display: block; margin-top: 10px; font: 500 34px Georgia, serif; }
.dashboard-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-top: 22px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin: 22px 0; }
.span-2 { grid-column: span 2; }

.panel { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 7px 24px rgba(34,29,35,.035); }
.panel + .panel { margin-top: 22px; }
.dashboard-grid .panel + .panel, .settings-grid .panel + .panel, .detail-grid .panel + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.panel-head h2 { margin: 4px 0 0; font: 500 22px Georgia, serif; }
.panel-head > a { font-size: 13px; font-weight: 700; }
.page-actions, .detail-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-actions p { margin: 0; color: var(--muted); }
.detail-head h2 { margin: 10px 0 3px; font: 500 34px Georgia, serif; }
.detail-head p { margin: 0; color: var(--muted); }
.prose { color: #4d5660; line-height: 1.75; }
.muted, .optional { color: var(--muted); font-size: 12px; }
.notice { padding: 15px 17px; margin-top: 20px; border-radius: 12px; background: #f4efe7; color: #675d50; font-size: 13px; line-height: 1.6; }

.button-row, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-weight: 750; font-size: 13px; transition: transform .15s, background .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--brand); color: #fff; box-shadow: 0 8px 18px rgba(111,76,114,.2); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.button.light { border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.14); color: #fff; backdrop-filter: blur(6px); }
.button.danger-outline { margin-left: auto; border-color: #e6c7c7; background: #fff; color: var(--danger); }
.button.large { min-height: 50px; width: 100%; }
.icon-button { border: 0; background: transparent; cursor: pointer; }
.text-button { padding: 0; border: 0; background: none; cursor: pointer; color: var(--brand); font-size: 12px; font-weight: 700; }
.danger { color: var(--danger) !important; }

.code-pill, .tag, .status-badge { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; font-weight: 800; letter-spacing: .05em; }
.code-pill { padding: 6px 9px; background: var(--brand-soft); color: var(--brand); font-size: 11px; }
.tag { padding: 4px 7px; background: #f0f1f2; color: #59616b; font-size: 9px; }
.status-badge { padding: 7px 11px; font-size: 10px; text-transform: uppercase; }
.status-badge.good { background: #e8f2eb; color: #52715c; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 0 5px #f6eddf; }
.file-badge { display: grid; flex: 0 0 auto; place-items: center; width: 43px; height: 50px; border-radius: 8px 8px 11px 11px; background: #f2e7e8; color: var(--rose); font-size: 10px; font-weight: 900; }
.supplier-mark { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 13px; }

.list-stack { display: grid; }
.list-row { display: flex; align-items: center; gap: 13px; min-height: 66px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.list-row:first-child { padding-top: 0; }
.list-row > div { min-width: 0; }
.list-row strong, .list-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row strong { font-size: 13px; }
.list-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.row-value { margin-left: auto; color: var(--muted); font-size: 12px; }
.empty-state { padding: 35px 15px; color: var(--muted); text-align: center; }
.success-state { color: var(--sage); }

.table-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 15px 18px; background: #faf9f7; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fcfbfa; }
.strong-link { color: var(--ink); font-weight: 750; }
.row-action { font-size: 12px; font-weight: 750; }
.table-sub { display: block; margin-top: 3px; color: var(--muted); }

.scent-card { min-height: 150px; }
.scent-card ul { margin: 18px 0 0; padding-left: 19px; color: #555e67; line-height: 1.8; }
.note-label { display: inline-flex; padding: 5px 10px; border-radius: 999px; font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.note-label.top { background: #f8e8eb; color: #9a5963; }
.note-label.middle { background: #eee8f2; color: #75517b; }
.note-label.base { background: #ebe9e2; color: #756c56; }

form label { display: grid; gap: 7px; color: #444c55; font-size: 12px; font-weight: 750; }
form label small { color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #dcd8d2; border-radius: 10px; outline: none; background: #fff; color: var(--ink); transition: border .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #a586a5; box-shadow: 0 0 0 3px rgba(111,76,114,.1); }
fieldset { padding: 22px; border: 1px solid var(--line); border-radius: 14px; }
legend { padding: 0 8px; font: 500 18px Georgia, serif; }
.form-stack { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-card { max-width: 920px; }
.form-actions { padding-top: 22px; margin-top: 22px; border-top: 1px solid var(--line); }
.compact { margin-top: 18px; }
.inline-create { margin-top: 20px; border-top: 1px solid var(--line); }
.inline-create summary { padding-top: 20px; cursor: pointer; color: var(--brand); font-size: 13px; font-weight: 750; }
.file-input { padding: 15px; border: 1px dashed #cabfca; border-radius: 12px; background: #fbf9fb; }
.file-input input { padding: 0; border: 0; min-height: auto; background: transparent; }
.choice-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.choice { display: flex; grid: none; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice input { width: auto; min-height: 0; margin: 4px 10px 0 0; }
.choice span { display: block; }
.choice strong, .choice small { display: block; }

.documents-grid { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 22px; align-items: start; }
.upload-card { position: sticky; top: 20px; }
.document-list { display: grid; gap: 12px; }
.document-card { display: flex; align-items: center; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; }
.document-main { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; color: var(--ink); }
.document-main h3 { margin: 5px 0 3px; font-size: 14px; }
.document-main p, .document-main small { margin: 0; color: var(--muted); font-size: 11px; }
.definition-list { margin: 0; }
.definition-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.definition-list > div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); font-size: 12px; }
.definition-list dd { margin: 0; font-size: 12px; font-weight: 750; text-align: right; }
code { padding: 2px 6px; border-radius: 5px; background: #f0edef; color: var(--brand); }

.alert { padding: 13px 16px; margin-bottom: 18px; border-radius: 11px; font-size: 13px; }
.alert.success { background: #e8f2eb; color: #496553; }
.alert.error { background: #f8e8e8; color: #8f3e3e; }

.auth-page { display: grid; place-items: center; padding: 30px 18px; background: radial-gradient(circle at 20% 10%, #eee5ed 0, transparent 35%), var(--canvas); }
.auth-card, .setup-card { width: min(100%, 430px); padding: clamp(28px, 5vw, 42px); border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.setup-card { width: min(100%, 760px); }
.auth-brand { color: var(--ink); }
.auth-brand small { color: var(--muted); }
.setup-heading { margin: 34px 0 25px; }
.setup-heading h1 { margin: 6px 0 10px; font: 500 34px Georgia, serif; }
.setup-heading p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }

@media (max-width: 1050px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .documents-grid { grid-template-columns: 1fr; }
    .upload-card { position: static; }
}

@media (max-width: 800px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; transform: translateX(-100%); width: 264px; transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.2); }
    .sidebar.open { transform: translateX(0); }
    .menu-button { display: block; font-size: 20px; }
    .topbar { min-height: 86px; padding-inline: 20px; }
    .content { padding-inline: 20px; }
    .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .hero-panel { align-items: flex-start; flex-direction: column; gap: 28px; }
}

@media (max-width: 560px) {
    .stat-grid, .form-grid, .choice-row { grid-template-columns: 1fr; }
    .page-actions, .detail-head { align-items: flex-start; flex-direction: column; }
    .page-actions .button, .detail-head .button-row { width: 100%; }
    .detail-head .button { flex: 1; }
    .panel { padding: 20px; }
    .hero-panel { padding: 28px 24px; }
    .button.danger-outline { margin-left: 0; }
    .form-actions .button { width: 100%; }
}
