:root {
    --bg: #f8fafb;
    --surface: #ffffff;
    --surface-2: #eff6f8;
    --ink: #102029;
    --muted: #5e6f77;
    --primary: #0f8b8d;
    --primary-ink: #ffffff;
    --accent: #f59e0b;
    --danger: #cf3e3e;
    --success: #1f8a4c;
    --border: #d9e5e9;
    --shadow: 0 20px 55px rgba(16, 32, 41, 0.08);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 90% -10%, rgba(245, 158, 11, 0.2), transparent 35%),
        radial-gradient(circle at -10% 20%, rgba(15, 139, 141, 0.15), transparent 40%),
        var(--bg);
    line-height: 1.5;
}

h1,
h2,
h3,
h4 {
    font-family: 'Sora', sans-serif;
    margin-top: 0;
    letter-spacing: -0.02em;
}

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

a {
    color: inherit;
    text-decoration: none;
}

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

main {
    flex: 1;
    padding-bottom: 3rem;
}

.container {
    width: min(1120px, calc(100% - 2rem));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(12px);
    background: rgba(248, 250, 251, 0.86);
    border-bottom: 1px solid rgba(217, 229, 233, 0.8);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 74px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
}

.brand-mark {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--primary), #18c7aa);
    box-shadow: inset 0 -2px 8px rgba(0, 0, 0, 0.18);
}

.main-nav {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
}

.main-nav a {
    color: var(--muted);
    font-weight: 600;
    padding: 0.45rem 0.7rem;
    border-radius: 9px;
}

.main-nav a:hover {
    color: var(--ink);
    background: var(--surface-2);
}

.hero {
    width: min(1120px, calc(100% - 2rem));
    margin: 2rem auto 1.2rem;
    display: grid;
    grid-template-columns: 1.2fr minmax(140px, 0.8fr);
    gap: 1rem;
    background: linear-gradient(145deg, #073042, #0f8b8d 55%, #11aa99);
    color: #f6fffe;
    border-radius: var(--radius-lg);
    padding: 2.2rem;
    position: relative;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero .eyebrow {
    color: rgba(246, 255, 254, 0.76);
}

.hero h1 {
    font-size: clamp(1.7rem, 3vw, 2.9rem);
    margin: 0.35rem 0 0.65rem;
}

.subtitle {
    color: var(--muted);
    margin-top: 0;
    margin-bottom: 1.1rem;
}

.hero .subtitle {
    color: rgba(246, 255, 254, 0.9);
    max-width: 58ch;
}

.hero-orb {
    width: min(260px, 100%);
    aspect-ratio: 1;
    margin-left: auto;
    border-radius: 50%;
    background:
        radial-gradient(circle at 40% 30%, rgba(255, 255, 255, 0.72), transparent 42%),
        radial-gradient(circle at 70% 70%, rgba(245, 158, 11, 0.95), rgba(245, 158, 11, 0) 68%),
        rgba(255, 255, 255, 0.16);
    filter: blur(0.2px);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.17), 0 14px 50px rgba(5, 29, 28, 0.35);
    align-self: center;
}

.hero-actions,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.eyebrow {
    margin: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    font-weight: 700;
}

.stats-grid {
    width: min(1120px, calc(100% - 2rem));
    margin: 1rem auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
}

.stat-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.stat-card h3 {
    margin: 0.4rem 0 0;
    font-size: 1.4rem;
}

.panel {
    width: min(1120px, calc(100% - 2rem));
    margin: 1rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.2rem;
}

.panel-tight {
    border-radius: var(--radius-md);
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.search-form input {
    flex: 1;
    min-width: 210px;
}

.products-wrap {
    width: min(1120px, calc(100% - 2rem));
    margin: 0.8rem auto;
}

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

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.product-top {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 0.8rem;
    align-items: center;
}

.product-top img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 12px;
}

.product-top h3 {
    margin-bottom: 0;
    font-size: 1rem;
}

.chip {
    display: inline-flex;
    padding: 0.22rem 0.58rem;
    background: var(--surface-2);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
    margin: 0 0 0.4rem;
    font-weight: 700;
}

.price-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 0.6rem;
}

.price-row h4 {
    margin: 0.1rem 0 0;
    font-size: 1.25rem;
}

.price-row .muted {
    margin: 0;
}

.trend {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.trend strong {
    font-size: 0.92rem;
}

.trend-up {
    color: var(--danger);
}

.trend-down {
    color: var(--success);
}

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

.price-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.card-foot {
    color: var(--muted);
    font-size: 0.76rem;
    margin: 0;
}

.btn {
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.72rem 1rem;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #0f8b8d, #0ea5a8);
    color: var(--primary-ink);
    box-shadow: 0 10px 22px rgba(15, 139, 141, 0.24);
}

.btn-secondary {
    background: #102029;
    color: #f8fbfb;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.14);
    color: #f5ffff;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn-danger {
    background: #5d1111;
    color: #fff2f2;
}

.alert {
    width: min(1120px, calc(100% - 2rem));
    margin: 1rem auto 0;
    padding: 0.88rem 1rem;
    border-radius: 12px;
    font-weight: 600;
}

.alert-success {
    background: #e9fbf1;
    color: #0b6e37;
    border: 1px solid #9cd5b3;
}

.alert-error {
    background: #fff1f1;
    color: #9d1e1e;
    border: 1px solid #f5b5b5;
}

.form-section {
    width: min(860px, calc(100% - 2rem));
    margin: 1.2rem auto;
}

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

.form-grid .full-width {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 0.34rem;
    font-size: 0.84rem;
    color: var(--muted);
    font-weight: 600;
}

small {
    font-size: 0.75rem;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    min-height: 44px;
    background: #fff;
    padding: 0.65rem 0.78rem;
    font: inherit;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(14, 165, 168, 0.2);
    border-color: var(--primary);
}

.toggle-field {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    grid-template-columns: auto 1fr;
}

.toggle-field input {
    min-height: auto;
    width: 18px;
    height: 18px;
    margin: 0;
}

.product-hero {
    width: min(1120px, calc(100% - 2rem));
    margin: 1.2rem auto 0;
    display: grid;
    grid-template-columns: 1.35fr minmax(180px, 0.8fr);
    gap: 1rem;
    align-items: center;
}

.product-image-wrap {
    background: linear-gradient(145deg, #e8f5f6, #fff8e8);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    min-height: 250px;
    display: grid;
    place-items: center;
}

.product-image-wrap img {
    max-height: 280px;
    object-fit: contain;
}

.product-stats {
    margin-top: 1rem;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.4rem;
}

.range-buttons {
    display: inline-flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.range-buttons button {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    border-radius: 999px;
    padding: 0.42rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.range-buttons button.is-active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

#priceChart {
    width: 100%;
    min-height: 320px;
    max-height: 380px;
}

.two-col-grid {
    width: min(1120px, calc(100% - 2rem));
    margin: 1rem auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.space-sm {
    margin-bottom: 0.9rem;
}

.inline-form {
    display: inline-flex;
}

.empty-state {
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1rem;
}

.muted {
    color: var(--muted);
    margin: 0;
    font-size: 0.86rem;
}

.admin-head h1 {
    margin-bottom: 0.4rem;
}

.admin-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.admin-head-actions {
    display: grid;
    gap: 0.35rem;
    justify-items: end;
    text-align: right;
}

.auth-wrap {
    width: min(560px, calc(100% - 2rem));
    margin: 1.2rem auto;
}

.auth-card h1 {
    margin-bottom: 0.45rem;
}

.auth-form {
    grid-template-columns: 1fr;
}

.auth-alert {
    width: 100%;
    margin: 0.7rem 0 0.9rem;
}

.admin-grid {
    margin-top: 0.2rem;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.5rem;
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.76rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.18rem 0.52rem;
    font-size: 0.72rem;
    font-weight: 700;
}

.status-pill.ok {
    color: #0b6e37;
    background: #e9fbf1;
    border: 1px solid #9cd5b3;
}

.status-pill.warn {
    color: #8a5f0a;
    background: #fff7e8;
    border: 1px solid #eec87f;
}

.chart-panel canvas {
    width: 100%;
    min-height: 280px;
    max-height: 320px;
}

.contract-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.code-block,
.log-lines {
    margin: 0;
    background: #0f1e27;
    color: #eaf6ff;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.85rem;
    font-size: 0.75rem;
    line-height: 1.45;
    overflow: auto;
    max-height: 290px;
}

.site-footer {
    margin-top: 1rem;
    border-top: 1px solid rgba(217, 229, 233, 0.8);
    background: rgba(255, 255, 255, 0.72);
}

.footer-row {
    min-height: 66px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.82rem;
}

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

@media (max-width: 860px) {
    .hero,
    .product-hero {
        grid-template-columns: 1fr;
        padding: 1.4rem;
    }

    .hero-orb {
        width: min(180px, 70%);
        margin-right: 0;
        justify-self: end;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-col-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .contract-grid {
        grid-template-columns: 1fr;
    }

    .admin-head-row {
        flex-direction: column;
    }

    .admin-head-actions {
        justify-items: start;
        text-align: left;
    }

    .form-grid .full-width {
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    .header-row {
        min-height: 64px;
    }

    .main-nav {
        gap: 0.25rem;
    }

    .main-nav a {
        padding: 0.35rem 0.42rem;
        font-size: 0.82rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .card-actions {
        grid-template-columns: 1fr;
    }

    .chart-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    #priceChart {
        min-height: 260px;
    }
}
