*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --amber:      #f5d800;
    --amber-dark: #4a3800;
    --text-dark:  #1c1917;
    --amber-pale: #fffde8;
    --sidebar-w:  220px;
    --topbar-h:   56px;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #fafaf9;
    color: var(--text-dark);
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-w);
    background: var(--text-dark);
    color: #e7e5e4;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
}

#sidebar .logo {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px;
    border-bottom: 1px solid #292524;
    text-decoration: none;
    transition: background .15s;
}
#sidebar .logo:hover          { background: #292524; }
#sidebar .logo .logo-hex      { color: var(--amber); flex-shrink: 0; }
#sidebar .logo:hover .logo-hex { opacity: .85; }

#sidebar .logo h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--amber);
    letter-spacing: .04em;
    line-height: 1.2;
}

#sidebar .logo p {
    font-size: .68rem;
    color: #a8a29e;
    margin-top: 2px;
    line-height: 1;
}

#sidebar nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    min-height: 0;
}

#sidebar nav a,
#sidebar .sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #d6d3d1;
    text-decoration: none;
    font-size: .875rem;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}

#sidebar nav a:hover,
#sidebar nav a.active,
#sidebar .sidebar-footer a:hover,
#sidebar .sidebar-footer a.active {
    background: #292524;
    color: var(--amber);
    border-left-color: var(--amber);
}

#sidebar .sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid #292524;
}

/* ── Content ── */
#content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 40px 48px;
    max-width: 900px;
}

.app-footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #e7e5e4;
    font-size: .8rem;
    color: #78716c;
}

.app-footer a {
    color: inherit;
}

/* ── Typography ── */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
}

/* ── Home ── */
.home-hero        { max-width: 560px; }
.home-brand       { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 28px; }
.home-brand-icon  { color: var(--amber); }
.home-title       { font-size: 2rem; font-weight: 800; color: var(--amber-dark); margin: 0; }
.home-sub         { font-size: .875rem; color: #78716c; margin: 0; }
.home-card        { margin-bottom: 24px; }
.home-description { font-size: .9rem; line-height: 1.6; color: #44403c; margin-bottom: 14px; }
.home-description:last-of-type { margin-bottom: 24px; }
.home-actions     { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-primary      { display: inline-block; padding: 10px 20px; background: var(--amber-dark); color: #fff; border-radius: 6px; text-decoration: none; font-size: .875rem; font-weight: 600; transition: opacity .15s; }
.btn-primary:hover { opacity: .85; }
.btn-secondary    { display: inline-block; padding: 10px 20px; border: 1px solid #d6d3d1; color: #44403c; border-radius: 6px; text-decoration: none; font-size: .875rem; font-weight: 500; transition: background .15s; }
.btn-secondary:hover { background: #f5f5f4; }
.home-features    { display: flex; flex-direction: column; gap: 12px; }
.home-feature     { display: flex; align-items: center; gap: 12px; font-size: .875rem; color: #57534e; }
.home-feature svg { flex-shrink: 0; color: var(--amber-dark); }
.home-security       { margin-top: 32px; padding-top: 24px; border-top: 1px solid #e7e5e4; }
.home-security-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #a8a29e; margin-bottom: 14px; }

/* ── Cards ── */
.card {
    background: #fff;
    border: 1px solid #e7e5e4;
    border-radius: 8px;
    padding: 28px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.card-grid .card { margin-bottom: 0; }

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

/* ── Stat cards ── */
.stat-card {
    display: flex;
    flex-direction: column;
    border-top: 3px solid var(--amber);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--amber-pale);
    border: 1px solid #fde68a;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--amber-dark);
    flex-shrink: 0;
}

.stat-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #a8a29e;
}

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin: 6px 0 20px;
    color: var(--text-dark);
}

.stat-number.muted {
    font-size: 2rem;
    color: #d6d3d1;
}

.stat-link {
    font-size: .8rem;
    font-weight: 500;
    color: #78716c;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: auto;
    transition: color .15s;
}

.stat-link:hover { color: var(--amber-dark); }

/* ── Hero ── */
.hero {
    background: var(--amber-pale);
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 36px 28px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.hero .bee { font-size: 3.5rem; line-height: 1; }

.hero h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--amber-dark);
}

.hero p {
    font-size: .9rem;
    color: #57534e;
    margin-top: 4px;
}

/* ── Buttons ── */
.btn-primary {
    background: var(--amber);
    color: var(--amber-dark);
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}

.btn-primary:hover { opacity: .85; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ── Button variants ── */
.btn-ghost {
    background: none;
    color: #ef4444;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-ghost:hover    { background: #fef2f2; }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
    background: none;
    color: var(--amber-dark);
    border: 1px solid var(--amber);
    border-radius: 6px;
    padding: 8px 18px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-secondary:hover { background: var(--amber-pale); }

.btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
.btn-danger:hover    { opacity: .85; }
.btn-danger:disabled { opacity: .5; cursor: not-allowed; }

.btn-link {
    background: none;
    border: none;
    color: #78716c;
    font-size: .85rem;
    cursor: pointer;
    padding: 8px 4px;
    text-decoration: underline;
}

.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn-row-del {
    background: none;
    border: 1px solid #e7e5e4;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: .8rem;
    cursor: pointer;
    color: #78716c;
    transition: border-color .15s, color .15s;
}
.btn-row-del:hover    { border-color: #fecaca; color: #ef4444; }
.btn-row-del:disabled { opacity: .5; cursor: not-allowed; }

/* ── Form inputs ── */
.form-input {
    width: 100%;
    border: 1px solid #e7e5e4;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: .875rem;
    font-family: inherit;
    background: #fff;
    outline: none;
    transition: border-color .15s;
}
.form-input:focus { border-color: var(--amber); }

.form-grid { display: grid; gap: 10px; }

/* ── Inline form panel ── */
.inline-form {
    border: 1px solid #e7e5e4;
    border-radius: 6px;
    padding: 16px;
    background: #fafaf9;
    margin-top: 16px;
}
.inline-form-title {
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ── Data table ── */
.data-table-wrap {
    overflow-x: auto;
    margin-bottom: 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
    margin-bottom: 4px;
}
.data-table th {
    text-align: left;
    padding: 6px 8px;
    color: #78716c;
    font-weight: 500;
    font-size: .8rem;
    border-bottom: 1px solid #e7e5e4;
}
.data-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #f5f5f4;
    vertical-align: middle;
    overflow-wrap: anywhere;
}
.data-table .muted    { color: #78716c; font-size: .8rem; }
.data-table .action-cell { text-align: right; }
.data-table .empty-row { color: #78716c; font-size: .85rem; }

/* ── Section header (title + status chip side-by-side) ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h2 { margin-bottom: 0; }

.err-msg { color: #ef4444; font-size: .85rem; margin-bottom: 12px; }
.login-err { margin-top: 10px; margin-bottom: 0; }

/* ── Utility classes (replace removed inline styles) ── */
.hint-text { color: #78716c; font-size: .875rem; }
.hint-text-mb { margin-bottom: 14px; }
.status-row-mb { margin-bottom: 16px; }
.load-label { font-size: .75rem; color: #78716c; margin-bottom: 4px; }
.load-value { font-size: 1.2rem; font-weight: 600; }
.btn-row-mt-sm { margin-top: 12px; }
.btn-row-mt    { margin-top: 16px; }
.audit-hidden  { display: none; }

/* ── Code output ── */
pre.result {
    margin-top: 14px;
    background: #f5f5f4;
    border-radius: 6px;
    padding: 14px;
    font-size: .8rem;
    overflow-x: auto;
    line-height: 1.6;
}

/* ── Status chips ── */
.status-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f5f5f4;
    border: 1px solid #e7e5e4;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: .8rem;
}

.status-chip.chip-red {
    background: #fef2f2;
    border-color: #fecaca;
}

.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.green  { background: #22c55e; }
.dot.yellow { background: var(--amber); }
.dot.gray   { background: #a8a29e; }
.dot.red    { background: #ef4444; }

/* ── Health table ── */
.health-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.health-table tr + tr td { border-top: 1px solid #f5f5f4; }

.health-table td {
    padding: 9px 4px;
    vertical-align: top;
}

.health-table td:first-child {
    color: #78716c;
    width: 44%;
    font-size: .8rem;
}

.health-table td:last-child {
    font-weight: 500;
    word-break: break-all;
}

/* ── Meter bar ── */
.meter-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.meter {
    flex: 1;
    height: 8px;
    background: #e7e5e4;
    border-radius: 4px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--amber);
}

.meter-fill.red   { background: #ef4444; }
.meter-fill.green { background: #22c55e; }

.meter-label {
    font-size: .78rem;
    color: #78716c;
    min-width: 48px;
    text-align: right;
}

/* ── Sidebar user block ── */
.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 20px;
    border-top: 1px solid #292524;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.sidebar-user-email {
    font-size: .75rem;
    color: #d6d3d1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: .65rem;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.sidebar-signout {
    background: none;
    border: none;
    color: #78716c;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    flex-shrink: 0;
    transition: color .15s;
}

.sidebar-signout:hover { color: #e7e5e4; }

/* ── Login page ── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #fafaf9;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
    padding: 24px 16px;
}

.login-card {
    background: #fff;
    border: 1px solid #e7e5e4;
    border-radius: 12px;
    padding: 40px 36px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-bee {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
    line-height: 1;
}

.login-logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: .04em;
}

.login-logo p {
    font-size: .75rem;
    color: #a8a29e;
    margin-top: 2px;
}

.login-submit {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    font-size: .9rem;
}

/* ── Device expandable detail row ── */
.device-detail-row td {
    background: var(--amber-pale);
    border-top: none;
    padding: 10px 14px 12px;
}

.device-detail-grid {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    font-size: .85rem;
}

.detail-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #a8a29e;
    margin-right: 6px;
}

.detail-warn { color: #b91c1c; font-weight: 600; }

/* ── Device detail: grouped sections ── */
.detail-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 32px;
}

.detail-group {
    min-width: 180px;
    max-width: 260px;
}

.detail-group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.detail-group-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--amber-dark);
    font-weight: 700;
    margin-bottom: 6px;
}

.detail-group-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .85rem;
}

.device-tab-panel {
    margin-top: 12px;
    max-width: 480px;
}

.device-tab-panel-wide {
    margin-top: 12px;
}

.settings-sensors {
    margin-bottom: 10px;
}

.heartbeat-log-wrap {
    overflow-x: auto;
    margin-top: 4px;
}

.heartbeat-log-table {
    min-width: 640px;
}

.error-summary-line {
    font-size: .78rem;
    color: #78716c;
    margin: 4px 0 14px;
}

.error-summary-line .detail-warn {
    font-weight: 600;
}

/* ── Stat boxes (used by Settings calibration values) ── */
.stat-boxes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 64px;
    padding: 8px 4px;
    border: 1px solid #e7e5e4;
    border-radius: 6px;
    background: #fafaf9;
    text-align: center;
}

.stat-box-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-box-value.warn {
    color: #b91c1c;
}

.stat-box-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #a8a29e;
}

/* ── Label/value table (Device/Hive detail panels) ── */
.kv-table {
    border-collapse: collapse;
    font-size: .85rem;
}

.kv-table td {
    padding: 4px 0;
    vertical-align: top;
}

.kv-table td:first-child {
    padding-right: 16px;
    white-space: nowrap;
}

.fw-newer-hint {
    font-size: .8rem;
    color: var(--amber-dark);
    margin-top: 8px;
}

.version-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .85rem;
}

.version-row .status-chip {
    flex-basis: 100%;
}

.version-current { font-weight: 600; }
.version-arrow { color: #a8a29e; }
.version-target { font-weight: 600; }

.status-chip.chip-green {
    background: #f0fdf4;
    border-color: #86efac;
}

.status-chip.chip-amber {
    background: var(--amber-pale);
    border-color: var(--amber);
}

.fw-pending-badge {
    margin-left: 6px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--amber-dark);
    background: var(--amber-pale);
    border: 1px solid var(--amber);
    border-radius: 10px;
    padding: 1px 8px;
    white-space: nowrap;
}

/* ── Labeled form fields ── */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #a8a29e;
}

/* ── Simulator ── */
.sim-form-grid {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 10px;
    margin-top: 16px;
}
.sim-input-row   { margin-top: 8px; }
.sim-fields-wrap { margin-top: 16px; }
.sim-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 6px;
}
.sim-response {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid;
}
.sim-response-tight { margin-top: 8px; }
.sim-response pre {
    margin: 4px 0 0;
    font-size: .85rem;
    white-space: pre-wrap;
}
.sim-ok  { background: #f0fdf4; border-color: #86efac; color: #166534; }
.sim-err { background: #fff1f2; border-color: #fca5a5; color: #991b1b; }

/* ── API key reveal box ── */
.api-key-box {
    margin-top: 14px;
    padding: 14px 16px;
    background: #fffde8;
    border: 1px solid var(--amber);
    border-radius: 8px;
}

.api-key-box p {
    font-size: .8rem;
    color: #4a3800;
    margin-bottom: 8px;
    font-weight: 600;
}

.api-key-box code {
    display: block;
    font-size: .8rem;
    word-break: break-all;
    background: #fff8c5;
    border: 1px solid #f5d800;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 10px;
    user-select: all;
}

/* ── Mobile top bar (hidden on desktop) ── */
#topbar  { display: none; }
#backdrop { display: none; }

/* ── Dashboard hive grid ── */
.hive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.hive-card {
    border-top: 3px solid var(--amber);
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 0;
    transition: box-shadow .15s, transform .15s;
}

.hive-card:hover {
    box-shadow: 0 4px 16px rgba(28, 25, 23, .08);
    transform: translateY(-1px);
}

.hive-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.hive-card-name { font-size: 1rem; font-weight: 700; }

.hive-location-chip { font-size: .75rem; padding: 2px 8px; }

.hive-metric-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.hive-metric-table td { padding: 5px 0; }
.hive-metric-table tr + tr td { border-top: 1px solid #f5f5f4; }

.metric-label { display: flex; align-items: center; gap: 6px; color: #78716c; font-size: .8rem; }
.metric-icon   { flex-shrink: 0; color: #a8a29e; }
.metric-value  { text-align: right; font-variant-numeric: tabular-nums; }
.metric-value strong { font-size: 1rem; }
.metric-unit   { font-size: .75rem; color: #78716c; margin-left: 2px; }

.hive-card-link { margin-top: auto; }
.hive-card-meta { margin-top: -8px; }

/* ── Hive detail page ── */
.hive-detail-title { margin-bottom: 0; }
.form-grid-mb      { margin-bottom: 1rem; }

.chart-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.period-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}
.period-nav-center { position: relative; }

.period-nav-label {
    background: none;
    border: none;
    font-size: .85rem;
    font-weight: 500;
    min-width: 180px;
    text-align: center;
    cursor: pointer;
    color: var(--text-dark);
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}
.period-nav-label:hover { background: #f5f5f4; }

.period-picker {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 100;
    min-width: 210px;
}
.picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.picker-year { font-weight: 600; font-size: .9rem; }
.picker-arrow {
    background: none;
    border: none;
    cursor: pointer;
    color: #78716c;
    display: flex;
    align-items: center;
    padding: 3px;
    border-radius: 4px;
}
.picker-arrow:hover { background: #f5f5f4; color: var(--text-dark); }
.picker-arrow:disabled { opacity: 0.3; cursor: default; }
.picker-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.picker-years  { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.picker-days   { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.picker-cell {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 2px;
    font-size: .8rem;
    cursor: pointer;
    text-align: center;
    color: var(--text-dark);
    transition: background .12s;
}
.picker-cell:hover:not(:disabled) { background: #f5f5f4; }
.picker-cell.active { background: var(--amber); border-color: var(--amber); color: var(--amber-dark); font-weight: 600; }
.picker-cell-muted { color: #c0bbba; }
.picker-cell:disabled { cursor: default; }
.period-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.period-nav-btn:hover:not(:disabled) { color: var(--text-dark); border-color: var(--text-muted); }
.period-nav-btn:disabled { opacity: 0.3; cursor: default; }

.hive-meta-card { padding-top: 12px; padding-bottom: 12px; }
.hive-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: .85rem;
}
.hive-meta-item .detail-label { margin-right: 0; }

.hive-detail-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .8rem;
    color: #78716c;
    text-decoration: none;
    margin-bottom: 4px;
}
.back-link:hover { color: var(--text-dark); }

.metric-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    margin-bottom: 12px;
    padding-bottom: 2px;
}

.metric-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 6px 14px;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    color: #78716c;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.metric-tab:hover { color: var(--text-dark); }
.metric-tab.active { color: var(--amber-dark); border-bottom-color: var(--amber); }

.chart-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.view-btns, .display-btns { display: flex; gap: 4px; }
.view-btn, .display-btn {
    background: none;
    border: 1px solid #e7e5e4;
    border-radius: 6px;
    padding: 5px 14px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    color: #78716c;
    transition: background .15s, border-color .15s, color .15s;
}
.view-btn:hover, .display-btn:hover { background: #f5f5f4; color: var(--text-dark); }
.view-btn.active, .display-btn.active { background: var(--amber); border-color: var(--amber); color: var(--amber-dark); }

.chart-wrap { position: relative; height: 300px; margin-bottom: 4px; }

.compare-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.year-chips        { display: flex; flex-wrap: wrap; gap: 6px; }
.year-chips .picker-cell { border: 1px solid #e7e5e4; }

.nav-section-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 14px 20px 4px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #78716c;
}
.nav-section-label:hover { color: #a8a29e; }
.nav-section-chevron { transition: transform .2s ease; }
.nav-section-chevron.closed { transform: rotate(-90deg); }

.chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .875rem;
    background: rgba(255,255,255,.8);
}

/* ── Mobile ── */
@media (max-width: 768px) {

    #topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        inset: 0 0 auto 0;
        height: var(--topbar-h);
        background: var(--text-dark);
        padding: 0 16px;
        z-index: 50;
    }

    #topbar .topbar-logo {
        font-size: 1rem;
        font-weight: 700;
        color: var(--amber);
        letter-spacing: .04em;
    }

    #topbar button {
        background: none;
        border: none;
        color: #e7e5e4;
        cursor: pointer;
        padding: 6px;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background .15s;
    }

    #topbar button:hover { background: #292524; }

    #sidebar {
        top: 0;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 60;
        width: 260px;
    }

    #sidebar.open { transform: translateX(0); }

    #sidebar .drawer-close {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 12px 16px 0;
    }

    #sidebar .drawer-close button {
        background: none;
        border: none;
        color: #a8a29e;
        cursor: pointer;
        padding: 4px;
        border-radius: 4px;
        display: flex;
        transition: color .15s;
    }

    #sidebar .drawer-close button:hover { color: #e7e5e4; }

    #backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 55;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }

    #backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    body { display: block; }

    #content {
        margin-left: 0;
        padding: 24px 16px;
        padding-top: calc(var(--topbar-h) + 24px);
    }

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

    .chart-controls .period-nav {
        width: 100%;
        justify-content: center;
    }

    .docs-layout { grid-template-columns: 1fr; }
}

/* ── Docs ── */
.docs-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 20px;
    align-items: start;
}

.docs-sidebar { padding: 16px; }

.docs-nav { display: flex; flex-direction: column; }

.docs-nav a {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: .85rem;
    color: #44403c;
    text-decoration: none;
}

.docs-nav a:hover,
.docs-nav a.active {
    background: var(--amber-pale);
    color: var(--amber-dark);
}

.markdown-body { font-size: .9rem; line-height: 1.6; color: #292524; }

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    color: var(--amber-dark);
    margin: 1.4em 0 .5em;
}
.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child { margin-top: 0; }

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body table,
.markdown-body blockquote { margin: 0 0 1em; }

.markdown-body ul,
.markdown-body ol { padding-left: 1.4em; }

.markdown-body code {
    background: #f5f5f4;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: .85em;
}

.markdown-body pre {
    background: #f5f5f4;
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
}
.markdown-body pre code { background: none; padding: 0; }

.markdown-body table { width: 100%; border-collapse: collapse; font-size: .85em; }
.markdown-body th,
.markdown-body td {
    padding: 6px 10px;
    border: 1px solid #e7e5e4;
    text-align: left;
}
.markdown-body th { background: #fafaf9; }

.markdown-body blockquote {
    border-left: 3px solid var(--amber);
    padding-left: 12px;
    color: #78716c;
}

.markdown-body a { color: var(--amber-dark); }
