:root {
    --primary: #2563eb;
    --secondary: #0f172a;
    --button: #0f172a;
    --accent: #f59e0b;
    --bg: #f7f8fb;
    --surface: #ffffff;
    --surface-soft: #f1f5f9;
    --line: #e2e8f0;
    --text: #111827;
    --muted: #64748b;
    --success: #15803d;
    --danger: #dc2626;
    --warning: #b45309;
    --shadow: 0 18px 38px rgba(15, 23, 42, .08);
    --shadow-soft: 0 8px 18px rgba(15, 23, 42, .055);
    --font: Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
main { min-height: calc(100vh - 68px); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 68px;
    padding: 12px clamp(18px, 4vw, 56px);
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--secondary);
    font-size: 15px;
    font-weight: 900;
}
.brand::before {
    content: "";
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--secondary);
    box-shadow: inset 0 -10px 0 rgba(37, 99, 235, .42);
}
.topbar nav, .tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.topbar nav a, .tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 11px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}
.topbar nav a:hover, .tabs a:hover {
    background: var(--surface-soft);
    color: var(--secondary);
}

.page, .store-hero, .catalog-layout, .product-detail {
    width: min(1200px, calc(100% - 36px));
    margin: 0 auto;
}
.page { padding: 32px 0 56px; }
.center-screen {
    min-height: calc(100vh - 68px);
    display: grid;
    place-items: center;
    padding: 24px;
}
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
    margin-bottom: 8px;
    color: var(--secondary);
    font-size: clamp(30px, 4.4vw, 52px);
    line-height: 1.03;
    letter-spacing: 0;
}
h2 {
    margin-bottom: 14px;
    color: var(--secondary);
    font-size: 21px;
    letter-spacing: 0;
}
h3 { margin-bottom: 10px; font-size: 16px; letter-spacing: 0; }
.muted { color: var(--muted); }
.eyebrow {
    color: var(--primary);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.flash {
    width: min(1200px, calc(100% - 36px));
    margin: 18px auto 0;
    padding: 12px 14px;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}
.panel + .panel { margin-top: 18px; }
.narrow { width: min(460px, 100%); }
.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 18px 0;
}
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stats div {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow-soft);
}
.stats strong {
    display: block;
    color: var(--secondary);
    font-size: 24px;
    line-height: 1.16;
}
.stats span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

label {
    display: grid;
    gap: 7px;
    margin-bottom: 12px;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}
input, select, textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { min-height: 104px; resize: vertical; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.form-grid .btn { grid-column: 1 / -1; }
.form-inline {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}
.form-inline label, .form-inline input { margin-bottom: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 15px;
    border: 0;
    border-radius: 7px;
    background: var(--secondary);
    color: #fff;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 14px rgba(15, 23, 42, .12);
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease, background .15s ease;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 20px rgba(15, 23, 42, .16);
}
.btn:disabled {
    opacity: .48;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.btn.secondary {
    background: #fff;
    color: var(--secondary);
    border: 1px solid var(--line);
    box-shadow: none;
}
.btn.danger { background: var(--danger); }
.btn.small {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 13px;
}

.store-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) 320px;
    align-items: stretch;
    gap: 18px;
    margin-top: 24px;
    color: var(--text);
}
.store-hero > div:first-child,
.hero-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.store-hero > div:first-child {
    display: grid;
    align-content: center;
    min-height: 300px;
    padding: clamp(28px, 5vw, 54px);
    border-left: 5px solid var(--primary);
}
.store-hero p {
    max-width: 620px;
    margin-bottom: 20px;
    color: var(--muted);
    font-size: 17px;
}
.store-hero h1 { margin-bottom: 12px; }
.hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.hero-card {
    display: grid;
    align-content: center;
    gap: 14px;
    min-height: 300px;
    padding: 24px;
    background:
        linear-gradient(180deg, #ffffff, #f8fafc);
}
.hero-card strong {
    display: block;
    color: var(--secondary);
    font-size: 34px;
}
.hero-card p { color: var(--muted); }
.logo {
    width: 76px;
    height: 76px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 16px;
}

.catalog-layout {
    display: grid;
    grid-template-columns: 270px 1fr;
    gap: 22px;
    padding: 26px 0 58px;
}
.filters {
    align-self: start;
    position: sticky;
    top: 88px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}
.filters h2 {
    margin-bottom: 14px;
    font-size: 17px;
}
.catalog-main { min-width: 0; }
.catalog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.catalog-head h2 { margin-bottom: 2px; }
.product-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.product-card {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.product-card:hover {
    transform: translateY(-3px);
    border-color: #bfdbfe;
    box-shadow: var(--shadow);
}
.product-body {
    display: grid;
    gap: 8px;
    padding: 15px;
}
.product-image, .placeholder {
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #eef2ff;
    color: var(--primary);
    font-size: 48px;
    font-weight: 900;
}
.product-image img, .gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.product-card h2 {
    min-height: 48px;
    margin: 0;
    font-size: 19px;
    line-height: 1.18;
}
.price-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}
.price-line strong {
    color: var(--secondary);
    font-size: 18px;
}

.product-detail {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(330px, .95fr);
    gap: 24px;
    align-items: start;
    padding: 34px 0 56px;
}
.gallery {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #eef2ff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.table, .timeline { display: grid; gap: 10px; }
.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row input, .row select { max-width: 180px; }
.shipment-row { flex-wrap: wrap; }
.danger-zone {
    margin-top: 18px;
    border-color: #fecaca;
    background: #fff7f7;
}
.branch-edit, .plan-edit {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}
.team-row {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.team-row:last-child { border-bottom: 0; }
.team-row .row { border-bottom: 0; padding-bottom: 8px; }
.branch-edit:last-child, .plan-edit:last-child { border-bottom: 0; }
.branch-edit .btn, .plan-edit .btn { align-self: end; }
.plan-edit { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.plan-edit label.checkbox-label, .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}
.plan-edit input[type="checkbox"], label input[type="checkbox"] {
    width: auto;
    min-height: auto;
}
.timeline div {
    display: grid;
    gap: 4px;
    padding: 12px 12px 12px 16px;
    background: var(--surface-soft);
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
}
.timeline small { color: var(--muted); }

.admin-page .section-head { align-items: center; }
.admin-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0 0 18px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}
.admin-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 11px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}
.admin-nav a:hover {
    background: var(--surface-soft);
    color: var(--secondary);
}
.admin-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.admin-record {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.admin-record:last-child { border-bottom: 0; }
.admin-record .row {
    border-bottom: 0;
    padding-bottom: 8px;
}
.admin-record .form-inline select { width: min(220px, 100%); }

@media (max-width: 920px) {
    .store-hero, .catalog-layout, .product-detail, .two-col, .form-grid {
        grid-template-columns: 1fr;
    }
    .branch-edit, .plan-edit { grid-template-columns: 1fr; }
    .filters { position: static; }
    .product-grid, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .section-head, .catalog-head {
        flex-direction: column;
        align-items: stretch;
    }
    .product-grid, .stats, .admin-stats { grid-template-columns: 1fr; }
    .row {
        align-items: flex-start;
        flex-direction: column;
    }
    .row input, .row select { max-width: none; }
    .store-hero {
        width: 100%;
        margin-top: 0;
    }
}
