:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-soft: #eef3f2;
    --text: #17201f;
    --muted: #667370;
    --line: #dbe3e0;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #b45309;
    --danger: #b91c1c;
    --success: #15803d;
    --shadow: 0 12px 30px rgba(20, 31, 29, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    display: block;
    max-width: 100%;
}

code,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

pre {
    max-width: 360px;
    max-height: 180px;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    font-size: 12px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 64px;
    padding: 12px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
}

.brand {
    color: var(--text);
    font-weight: 800;
    letter-spacing: 0;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.nav a {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 8px;
}

.nav a:hover {
    background: var(--surface-soft);
    text-decoration: none;
}

.page {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 28px clamp(14px, 3vw, 34px) 56px;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

h1,
h2,
h3 {
    margin: 0 0 10px;
    letter-spacing: 0;
    line-height: 1.15;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 16px;
}

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

.small {
    font-size: 12px;
}

.hint {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

.alert {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    background: var(--surface);
}

.alert-success {
    border-color: rgba(21, 128, 61, 0.28);
    background: #effaf3;
    color: #166534;
}

.alert-error {
    border-color: rgba(185, 28, 28, 0.25);
    background: #fff1f1;
    color: #991b1b;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.inline-auth {
    min-height: auto;
    padding: 24px 0;
}

.auth-card,
.panel-card,
.metric-card,
.product-card,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(460px, 100%);
    padding: 26px;
}

.panel-card {
    padding: 20px;
}

.panel-card.narrow {
    width: min(560px, 100%);
}

.separator {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 18px;
}

.form-stack {
    display: grid;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(15, 118, 110, 0.24);
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 13px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    white-space: nowrap;
}

.btn:hover {
    background: var(--surface-soft);
    text-decoration: none;
}

.btn.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.danger {
    border-color: rgba(185, 28, 28, 0.35);
    color: var(--danger);
}

.btn.small {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 12px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.metric-card {
    padding: 18px;
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1;
}

.compact-metric {
    min-width: 190px;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 18px;
    align-items: start;
}

.two-col.wide-left {
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
}

.table-wrap {
    overflow: auto;
}

.table-wrap.compact {
    margin-top: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.status,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
}

.badge {
    margin-left: 8px;
    background: #fff7ed;
    color: var(--accent);
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.check-grid legend {
    padding: 0 6px;
    color: var(--muted);
    font-weight: 800;
}

.check-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.check-grid input {
    width: auto;
    min-height: auto;
}

.thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.product-card {
    overflow: hidden;
}

.product-media {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    background: #e9efed;
    color: var(--primary-dark);
    font-size: 34px;
    font-weight: 900;
}

.product-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-body {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.product-body h2 {
    margin: 0;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.product-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 22px;
    align-items: start;
    margin-bottom: 20px;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.gallery img,
.media-placeholder {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #e9efed;
}

.media-placeholder {
    display: grid;
    place-items: center;
    color: var(--primary-dark);
    font-size: 42px;
    font-weight: 900;
}

.product-summary {
    position: sticky;
    top: 88px;
}

.price {
    margin: 0 0 12px;
    color: var(--primary-dark);
    font-size: 24px;
    font-weight: 900;
}

.order-form-card {
    width: min(920px, 100%);
}

.detail-list {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 8px 14px;
    margin: 0;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 800;
}

.detail-list dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.empty-state {
    padding: 28px;
    text-align: center;
}

@media (max-width: 1100px) {
    .metric-grid,
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-col,
    .two-col.wide-left,
    .product-detail {
        grid-template-columns: 1fr;
    }

    .product-summary {
        position: static;
    }
}

@media (max-width: 720px) {
    .topbar,
    .section-head {
        display: grid;
    }

    .nav {
        justify-content: flex-start;
    }

    .metric-grid,
    .product-grid,
    .form-grid,
    .gallery,
    .check-grid {
        grid-template-columns: 1fr;
    }

    .inline-form {
        display: grid;
        width: 100%;
    }

    .detail-list {
        grid-template-columns: 1fr;
    }
}
