@font-face {
    font-family: "Cabinet Grotesk";
    src: url("/static/fonts/cabinet-grotesk-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Cabinet Grotesk";
    src: url("/static/fonts/cabinet-grotesk-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #FAF9F6;
    --surface: #FFFFFF;
    --text: #17181A;
    --muted: #7A7D82;
    --border: #E7E5DF;
    --accent: #1F9D5C;
    --accent-deep: #147A46;
    --accent-hover: #147A46;
    --accent-glow: rgba(31,157,92,0.22);
    --warn: #B45309;
    --err: #B42318;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-sm: 7px;
    --font-display: "Cabinet Grotesk", -apple-system, "Segoe UI", sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
    --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

:root[data-theme="dark"] {
    --bg: #101214;
    --surface: #191C20;
    --text: #F1F2F3;
    --muted: #8D9298;
    --border: #2A2E34;
    --accent: #34C07F;
    --accent-deep: #26A06A;
    --accent-hover: #26A06A;
    --accent-glow: rgba(52,192,127,0.28);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #101214;
        --surface: #191C20;
        --text: #F1F2F3;
        --muted: #8D9298;
        --border: #2A2E34;
        --accent: #34C07F;
        --accent-deep: #26A06A;
        --accent-hover: #26A06A;
        --accent-glow: rgba(52,192,127,0.28);
    }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(20px) saturate(160%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
    padding: 0 8px 20px;
}
.brand:hover { text-decoration: none; }
.brand-accent { color: var(--accent); }

.nav-section { position: relative; display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.nav-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--muted);
    padding: 12px 8px 5px;
}

.nav-spotlight {
    position: absolute;
    left: 0; right: 0;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    box-shadow: 0 4px 14px var(--accent-glow);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transition: transform 0.32s var(--ease-spring), opacity 0.18s var(--ease-spring), height 0.2s var(--ease-spring);
}
.nav-section:hover .nav-spotlight, .nav-spotlight.pinned { opacity: 1; }

.nav-link {
    position: relative;
    z-index: 1;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.87rem;
    transition: color 0.18s var(--ease-spring);
}
.nav-link:hover { text-decoration: none; }
.nav-link.active { color: #fff; font-weight: 600; }
.nav-section:hover .nav-link.active:not(:hover) { color: var(--text); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.sidebar-btn { width: 100%; }

.theme-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.theme-row span { font-size: 0.78rem; color: var(--muted); }
.theme-toggle {
    position: relative;
    width: 44px; height: 25px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}
.theme-toggle .knob {
    width: 19px; height: 19px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px;
    transform: translateX(0);
    transition: transform 0.32s var(--ease-spring);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
:root[data-theme="dark"] .theme-toggle .knob { transform: translateX(19px); }

.content { flex: 1; padding: 32px 40px; max-width: 1100px; }
.content-auth {
    max-width: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 0;
}

.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.content-header h1 { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; letter-spacing: -0.015em; margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.03);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    transition: transform 0.15s var(--ease-spring), box-shadow 0.18s var(--ease-spring), background 0.15s;
}
.btn:hover { background: var(--accent-deep); text-decoration: none; box-shadow: 0 8px 18px var(--accent-glow); }
.btn:active { transition-duration: 0.06s; transform: scale(0.97); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: var(--bg); box-shadow: none; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none !important; transform: none !important; }

.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.55);
    transform: scale(0);
    animation: mfRippleOut 0.55s ease-out forwards;
    pointer-events: none;
}
@keyframes mfRippleOut { to { transform: scale(2.6); opacity: 0; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); font-size: 0.89rem; }
th { color: var(--muted); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { transition: background 0.15s var(--ease-spring); }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.muted { color: var(--muted); }

.status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--bg);
    border: 1px solid var(--border);
}
.status-new { background: #EAF2FF; color: #1D4ED8; border-color: #C7DBFF; }
.status-to_pack { background: #FFF4E5; color: var(--warn); border-color: #FCE3B6; }
.status-shipped { background: #EAF6EE; color: var(--accent-deep); border-color: #CDEBD8; }
.status-delivered { background: #EFEFEF; color: var(--muted); border-color: var(--border); }
.status-cancelled, .status-returned { background: #FDECEC; color: var(--err); border-color: #F8CFCF; }

.category-group { margin-bottom: 28px; }
.category-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; margin: 0 0 10px; color: var(--muted); }

.form-card { width: 380px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; margin-bottom: 4px; color: var(--muted); }

input[type="text"], input[type="password"], input[type="email"], select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s var(--ease-spring), box-shadow 0.15s var(--ease-spring);
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 30px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237A7D82' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
}

input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

.error-box {
    background: #FDECEC;
    border: 1px solid #F8CFCF;
    color: var(--err);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.permission-grid { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px 16px; align-items: center; }
.permission-grid .head { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); }

/* Кастомный дропдаун - прогрессивно заменяет вид нативного <select> (см.
   enhanceSelects() в base.html). Сам <select> остаётся в DOM скрытым, но
   рабочим - формы и существующие change-обработчики продолжают работать. */
select.dd-native-hidden {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}
.dd { position: relative; width: 100%; }
.dd-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.18s var(--ease-spring), box-shadow 0.18s var(--ease-spring);
}
.dd-trigger:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.dd.open .dd-trigger { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chevron {
    width: 8px; height: 8px; flex-shrink: 0; margin-top: -3px;
    border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.3s var(--ease-spring);
}
.dd.open .dd-chevron { transform: rotate(-135deg); margin-top: 3px; }

.dd-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 100%;
    z-index: 30;
    max-height: 280px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 34px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.06);
    padding: 6px;
    transform-origin: top left;
    opacity: 0;
    transform: translateY(-6px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.16s var(--ease-spring), transform 0.22s var(--ease-spring);
}
.dd.open .dd-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.dd-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.87rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.12s var(--ease-spring), color 0.12s;
}
.dd-opt:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.dd-opt.selected { color: var(--accent-deep); font-weight: 600; }
.dd-opt .dd-check {
    opacity: 0; transform: scale(0.5); color: var(--accent); font-size: 0.8rem; flex-shrink: 0;
    transition: opacity 0.15s var(--ease-spring), transform 0.15s var(--ease-spring);
}
.dd-opt.selected .dd-check { opacity: 1; transform: scale(1); }

/* Курсор-прожектор - лёгкое свечение, следующее за указателем по всей странице. */
.mf-cursor-glow {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(480px circle at var(--px, 50%) var(--py, 50%), var(--accent-glow), transparent 65%);
    opacity: 0;
    transition: opacity 0.4s;
}
.mf-cursor-glow.on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
    .mf-cursor-glow { display: none; }
}
