@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
    color-scheme: light;
    --ink: #17283b;
    --ink-soft: #415268;
    --muted: #6c7b8d;
    --line: #dce3e9;
    --paper: #ffffff;
    --canvas: #f2f5f7;
    --navy: #0c2238;
    --navy-light: #173c5b;
    --orange: #e9682b;
    --orange-hover: #cf4e17;
    --orange-pale: #fff0e8;
    --green: #23824b;
    --red: #b33434;
    --radius: 8px;
    --shadow: 0 24px 70px -35px rgba(8, 29, 49, .42);
    --font: 'DM Sans', 'Segoe UI', sans-serif;
    --display: 'Manrope', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background: linear-gradient(135deg, #e8eef2 0%, #f6f7f8 52%, #e8edf0 100%);
}
.login-layout {
    display: grid;
    grid-template-columns: minmax(320px, .92fr) minmax(390px, 1.08fr);
    width: min(100%, 980px);
    min-height: 590px;
    overflow: hidden;
    border: 1px solid rgba(14, 35, 55, .1);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: var(--shadow);
    animation: enter .45s ease both;
}
.login-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 58px;
    color: #fff;
    background:
        radial-gradient(700px 360px at 8% 0%, rgba(233, 104, 43, .22), transparent 55%),
        linear-gradient(150deg, var(--navy-light), var(--navy) 72%);
}
.login-brand img { width: 68px; height: 68px; object-fit: contain; padding: 5px; border-radius: 10px; background: #fff; }
.login-kicker, .eyebrow { margin: 34px 0 8px; color: var(--orange); font-size: .73rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login-brand h1 { margin: 0; font-family: var(--display); font-size: 2.45rem; line-height: 1.1; font-weight: 800; }
.login-description { max-width: 280px; margin: 16px 0 0; color: rgba(255,255,255,.72); }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: 64px clamp(36px, 7vw, 82px) 28px; }
.login-form-wrap { width: 100%; max-width: 360px; margin: auto; }
.login-panel .eyebrow { margin: 0 0 8px; }
.login-panel h2 { margin: 0; font-family: var(--display); font-size: 1.8rem; font-weight: 800; }
.login-help { margin: 8px 0 28px; color: var(--muted); }
.login-form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; color: var(--ink-soft); font-size: .86rem; font-weight: 700; }
.field input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); outline: none; background: #fbfcfd; transition: border-color .15s, box-shadow .15s, background .15s; }
.field input:focus { border-color: var(--orange); background: #fff; box-shadow: 0 0 0 3px rgba(233,104,43,.13); }
.button { min-height: 46px; padding: 10px 18px; border: 1px solid transparent; border-radius: var(--radius); font-weight: 750; cursor: pointer; transition: background .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { margin-top: 4px; background: var(--orange); color: #fff; }
.button-primary:hover { background: var(--orange-hover); }
.form-message { margin: 0 0 18px; padding: 11px 13px; border: 1px solid #f1c8b7; border-radius: var(--radius); background: var(--orange-pale); color: #8e3d1c; font-size: .88rem; }
.login-footer { margin: 34px 0 0; padding-top: 18px; border-top: 1px solid #edf0f2; color: var(--muted); font-size: .76rem; text-align: center; }

.app-body { min-height: 100vh; background: var(--canvas); }
.skip-link { position: absolute; z-index: 100; top: -50px; left: 16px; padding: 10px 14px; border-radius: 6px; background: #fff; color: var(--ink); }
.skip-link:focus { top: 12px; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; display: flex; flex-direction: column; width: 258px; padding: 20px 14px; color: rgba(255,255,255,.78); background: radial-gradient(460px 280px at 0 0, rgba(233,104,43,.2), transparent 62%), linear-gradient(180deg, #102d48, #0b1c2d 82%); }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.1); color: inherit; text-decoration: none; }
.brand-logo { width: 44px; height: 44px; padding: 3px; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; background: #fff; object-fit: contain; }
.brand-text, .sidebar-user > span:last-child { display: grid; gap: 2px; min-width: 0; }
.brand-text strong { color: #fff; font-family: var(--display); font-size: .9rem; }
.brand-text small, .sidebar-user small { color: rgba(255,255,255,.56); font-size: .7rem; }
.nav { display: grid; gap: 4px; padding: 18px 0; }
.nav-section { margin: 14px 10px 5px; color: rgba(255,255,255,.43); font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.nav-link, .logout-link { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 11px; border-radius: 6px; color: rgba(255,255,255,.72); font-size: .84rem; font-weight: 600; text-decoration: none; }
.nav-link:hover, .nav-link.is-active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-link.is-active { box-shadow: inset 3px 0 var(--orange); }
.nav-icon { width: 18px; height: 18px; }
.sidebar-foot { display: grid; gap: 12px; margin-top: auto; padding: 14px 5px 0; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 4px; }
.sidebar-user strong { overflow: hidden; color: #fff; font-size: .8rem; text-overflow: ellipsis; }
.logout-link { min-height: 36px; padding-left: 8px; color: rgba(255,255,255,.62); font-size: .78rem; }
.logout-form { margin: 0; }
.logout-link { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; }
.logout-link:hover { color: #fff; text-decoration: none; }
.app-main { min-height: 100vh; margin-left: 258px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; min-height: 82px; padding: 14px 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); backdrop-filter: blur(12px); }
.page-heading h1 { margin: 0; font-family: var(--display); font-size: 1.26rem; font-weight: 800; }
.page-heading p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }
.topbar-user { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--ink-soft); font-size: .78rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #e8eef3; color: #284660; font-size: .78rem; font-weight: 800; }
.content { width: min(100%, 1700px); margin: 0 auto; padding: 24px 30px 48px; }
.mobile-menu, .sidebar-overlay { display: none; }
.icon, .icon-sm { width: 20px; height: 20px; flex: 0 0 auto; }
.icon-sm { width: 16px; height: 16px; }
.panel { margin-bottom: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: 0 2px 8px rgba(18,39,59,.035); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 20px; border-bottom: 1px solid #e8edf0; }
.panel-head h2 { margin: 0; font-family: var(--display); font-size: .98rem; font-weight: 800; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: .76rem; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { display: flex; align-items: flex-start; gap: 13px; min-height: 104px; padding: 17px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.stat-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 8px; }
.stat-icon svg { width: 19px; height: 19px; }
.tone-slate { background: #edf1f4; color: #496076; }
.tone-info { background: #e7f2f8; color: #1979a8; }
.tone-warm { background: var(--orange-pale); color: var(--orange); }
.stat-label { margin: 0; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.stat-value { margin: 3px 0 0; font-family: var(--display); font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-total { color: var(--muted); font-size: .92rem; }
.stat-meta { margin: 1px 0 0; color: var(--muted); font-size: .72rem; }
.panel-summary { cursor: pointer; list-style: none; }
.panel-summary::-webkit-details-marker { display: none; }
.panel-title-wrap { display: flex; align-items: center; gap: 12px; }
.panel-title-wrap > span:last-child { display: grid; gap: 3px; }
.panel-title-wrap strong { font-family: var(--display); font-size: .95rem; }
.panel-title-wrap small { color: var(--muted); font-size: .75rem; }
.summary-caret { color: var(--muted); font-size: 1.1rem; transition: transform .18s ease; }
.entry-panel details:not([open]) .summary-caret { transform: rotate(-90deg); }
.record-form { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; padding: 18px 20px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--ink-soft); font-size: .75rem; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #d5dee5; border-radius: 6px; outline: 0; background: #fcfdfe; color: var(--ink); font-size: .82rem; font-weight: 500; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(233,104,43,.12); background: #fff; }
.field-wide { grid-column: span 2; }
.form-actions { display: flex; align-items: end; justify-content: flex-end; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 13px; border: 1px solid transparent; border-radius: 6px; font-size: .78rem; font-weight: 750; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer; }
.button:hover { text-decoration: none; }
.button-primary { background: var(--orange); color: #fff; }
.button-primary:hover { background: var(--orange-hover); }
.button-secondary { border-color: #cdd7df; background: #fff; color: var(--ink-soft); }
.button-secondary:hover { border-color: #aebdc9; background: #f7f9fa; color: var(--ink); }
.filter-panel details > summary { display: flex; align-items: center; gap: 8px; padding: 14px 20px; color: var(--ink-soft); font-size: .8rem; font-weight: 750; cursor: pointer; list-style: none; }
.filter-panel details > summary::-webkit-details-marker { display: none; }
.filter-form { padding: 16px 20px 20px; border-top: 1px solid #e8edf0; background: #fbfcfd; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.filter-actions { display: flex; gap: 8px; margin-top: 14px; }
.flash { margin: 0 0 14px; padding: 12px 14px; border: 1px solid; border-radius: 6px; font-size: .84rem; }
.flash-success { border-color: #c4e6d1; background: #edf8f1; color: #226e41; }
.flash-danger { border-color: #efc9c5; background: #fff1ef; color: #963d34; }
.table-head { align-items: center; }
.table-wrap { width: 100%; max-height: 68vh; overflow: auto; }
.data-table { width: 100%; min-width: 1150px; border-collapse: separate; border-spacing: 0; font-size: .76rem; }
.data-table thead th { position: sticky; top: 0; z-index: 2; padding: 10px 11px; border-bottom: 1px solid var(--line); background: #f5f8fa; color: #56697c; font-size: .65rem; font-weight: 800; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table tbody td { max-width: 200px; padding: 11px; border-bottom: 1px solid #edf1f3; vertical-align: top; }
.data-table tbody tr:hover td { background: #fbfcfd; }
.sort-link { display: inline-flex; align-items: center; gap: 5px; color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--orange-hover); text-decoration: none; }
.date-cell { white-space: nowrap; }
.date-cell strong, .date-cell small { display: block; }
.date-cell small, .muted { color: var(--muted); }
.small { font-size: .7rem; }
.text-cell { max-width: 175px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 4px; font-size: .65rem; font-weight: 800; white-space: nowrap; }
.badge-success { background: #e5f4eb; color: #287448; }
.badge-danger { background: #fff0ed; color: #a44136; }
.badge-info { background: #e7f2f8; color: #286d91; }
.num { text-align: center; font-variant-numeric: tabular-nums; }
.actions-col { width: 94px; white-space: nowrap; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid #d5dee5; border-radius: 6px; background: #fff; color: #52677b; cursor: pointer; }
.icon-button:hover { border-color: #aebdc9; background: #f5f8fa; color: var(--ink); }
.danger-action:hover { border-color: #e3b4af; background: #fff1ef; color: #a44136; }
.inline-form { display: inline; margin: 0; }
.empty-state { padding: 35px 20px; text-align: center; }
.empty-state h3 { margin: 0; font-family: var(--display); font-size: .95rem; }
.empty-state p { margin: 6px 0 0; color: var(--muted); font-size: .78rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; border-top: 1px solid #edf1f3; color: var(--muted); font-size: .75rem; }
.pagination a { color: #355a78; font-weight: 700; text-decoration: none; }
.pagination a:hover { color: var(--orange-hover); }
.edit-dialog { width: min(760px, calc(100% - 28px)); max-height: min(92vh, 900px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.edit-dialog::backdrop { background: rgba(8,24,39,.58); backdrop-filter: blur(2px); }
.edit-form { grid-template-columns: repeat(2, minmax(0,1fr)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; grid-column: 1 / -1; margin: -18px -20px 6px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.dialog-head .eyebrow { margin: 0 0 4px; }
.dialog-head h2 { margin: 0; font-family: var(--display); font-size: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 5px; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.catalog-add-form { display: flex; align-items: end; gap: 8px; padding: 14px 16px; border-bottom: 1px solid #e8edf0; }
.catalog-add-form .field { flex: 1; }
.catalog-add-form .button { flex: 0 0 auto; }
.catalog-list { max-height: 55vh; overflow-y: auto; margin: 0; padding: 4px 16px 12px; list-style: none; }
.catalog-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 43px; border-bottom: 1px solid #edf1f3; color: var(--ink-soft); font-size: .79rem; }
.catalog-list li:last-child { border-bottom: 0; }
.user-table { min-width: 1050px; }
.user-edit-form { display: grid; grid-template-columns: 1fr 1.3fr .9fr 1fr auto; align-items: center; gap: 6px; }
.user-edit-form input, .user-edit-form select { min-width: 0; min-height: 34px; padding: 5px 7px; border: 1px solid #d5dee5; border-radius: 5px; background: #fff; font-size: .72rem; }
.user-edit-form .button { min-height: 34px; padding: 6px 9px; font-size: .7rem; }

@media (max-width: 1100px) {
    .content { padding: 20px; }
    .topbar { padding: 13px 20px; }
    .filter-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .record-form { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .catalog-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-overlay:not([hidden]) { position: fixed; inset: 0; z-index: 40; display: block; background: rgba(8,24,39,.46); }
    .app-main { margin-left: 0; }
    .mobile-menu { display: inline-grid; flex: 0 0 auto; }
    .topbar { min-height: 70px; gap: 10px; padding: 11px 14px; }
    .page-heading h1 { font-size: 1.04rem; }
    .page-heading p { max-width: 55vw; overflow: hidden; font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-user strong { display: none; }
    .content { padding: 14px 12px 32px; }
    .stats-grid { gap: 8px; }
    .stat-card { min-height: 92px; gap: 9px; padding: 12px; }
    .stat-value { font-size: 1.08rem; }
    .panel-head { align-items: flex-start; padding: 14px; }
    .table-head { flex-direction: column; }
    .panel-actions { flex-wrap: wrap; }
    .record-form, .filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; padding: 14px; }
    .filter-form { padding: 13px 14px 16px; }
    .field-wide { grid-column: 1 / -1; }
    .dialog-head { margin: -14px -14px 4px; padding: 14px; }
    .edit-form { grid-template-columns: 1fr; }
    .pagination { flex-wrap: wrap; gap: 8px; }
}
@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filter-grid, .record-form { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .form-actions { justify-content: stretch; }
    .form-actions .button { width: 100%; }
}

@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 720px) {
    .login-page { padding: 18px; }
    .login-layout { grid-template-columns: 1fr; min-height: auto; max-width: 480px; }
    .login-brand { min-height: 220px; padding: 30px 32px; }
    .login-brand img { width: 50px; height: 50px; }
    .login-kicker { margin-top: 18px; }
    .login-brand h1 { font-size: 1.8rem; }
    .login-description { margin-top: 8px; }
    .login-panel { min-height: 355px; padding: 38px 30px 22px; }
}
