:root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-green: #10b981;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; background: var(--bg); color: var(--text); padding: 2rem 0; }
.container { width: 90vw; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }

header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 1rem; flex-wrap: wrap; gap: 1rem; }
header h1 a { color: var(--text); text-decoration: none; font-size: 1.4rem; }
.app-brand { display: inline-flex; align-items: center; }
.app-logo { max-height: 54px; max-width: 300px; width: auto; height: auto; object-fit: contain; display: block; }
nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
nav a { color: var(--text-muted); text-decoration: none; font-size: 0.95rem; }
nav a:hover { color: var(--accent); }
.user-menu { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; font-size: 0.85rem; }
.user-menu a { color: var(--accent); text-decoration: none; }

main { display: flex; flex-direction: column; gap: 1.5rem; }

.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.75rem; }
.card h2 { font-size: 1.2rem; }
.muted { color: var(--text-muted); font-weight: 400; font-size: 0.85rem; }

.empty-state { color: var(--text-muted); padding: 1.5rem; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }

.button { display: inline-block; background: var(--accent); color: #0f172a; padding: 0.5rem 1rem; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; }
.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; }
.table-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin: 1rem 0; }
.table-pagination label, .page-navigation { display: flex; align-items: center; gap: 0.5rem; }
.page-navigation { flex-wrap: wrap; }
.table-pagination input { width: 6rem; padding: 0.4rem; }
.page-summary { color: var(--text-muted); font-size: 0.85rem; }
.page-navigation .button { width: 2.5rem; height: 2.5rem; padding: 0; font-size: 1.5rem; }
.page-navigation .button:disabled { opacity: 0.4; cursor: default; }
.table-search { margin-bottom: 0.75rem; }
.table-search-input {
    width: 100%; max-width: 320px; background: #0f172a; border: 1px solid var(--border); color: var(--text);
    padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.9rem; font-family: inherit;
}
.table-search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable::after { content: '\21C5'; margin-left: 0.4rem; font-size: 0.85em; opacity: 0.4; }
.data-table th.sortable.sorted-asc::after { content: '\25B2'; opacity: 1; color: var(--accent); }
.data-table th.sortable.sorted-desc::after { content: '\25BC'; opacity: 1; color: var(--accent); }
.data-table a { color: var(--accent); text-decoration: none; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat-card { background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.stat-card .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 1.3rem; font-weight: 700; margin-top: 0.25rem; }

.chart-wrap { margin: 1rem 0; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { fill: var(--text-muted); font-size: 11px; }
.chart-axis-label.chart-axis-time { fill: var(--accent); }
.chart-axis-label.chart-axis-mah { fill: var(--accent-green); }
.chart-line { fill: none; stroke-width: 2; }
.chart-line-time { stroke: var(--accent); }
.chart-line-mah { stroke: var(--accent-green); }
.chart-dot.chart-line-time { fill: var(--accent); }
.chart-dot.chart-line-mah { fill: var(--accent-green); }
.chart-legend { display: flex; gap: 1.5rem; margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-muted); flex-wrap: wrap; }
.chart-legend-item { display: flex; align-items: center; gap: 0.4rem; }
.chart-swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.chart-swatch.chart-line-time { background: var(--accent); }
.chart-swatch.chart-line-mah { background: var(--accent-green); }

.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.spec-item { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; font-size: 0.9rem; }
.spec-item .label { color: var(--text-muted); }
.telemetry-title { min-width: 0; overflow-wrap: anywhere; }
.telemetry-actions { flex-wrap: wrap; }
.telemetry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1.5rem; }
.telemetry-plot { min-width: 0; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.telemetry-plot h3 { font-size: 0.95rem; overflow-wrap: anywhere; margin-bottom: 0.5rem; }
.telemetry-canvas { min-width: 0; }
.telemetry-plot .u-legend { color: var(--text); font-size: 0.75rem; max-width: 100%; }
.telemetry-selectors { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; margin: 1rem 0; }
.telemetry-selectors label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; max-width: 100%; overflow-wrap: anywhere; }
.telemetry-selectors input { flex: 0 0 auto; }
.telemetry-swatch { display: inline-block; width: 0.6rem; height: 0.6rem; flex: 0 0 0.6rem; }
.telemetry-labels > div { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0.75rem; padding: 0.5rem 0; }
.telemetry-labels label, .telemetry-labels input { min-width: 0; }
.radio-title { overflow-wrap: anywhere; min-width: 0; }
.radio-actions { flex-wrap: wrap; }
.radio-specs { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.radio-source { max-height: 36rem; overflow: auto; padding: 1rem; border: 1px solid var(--border); border-radius: 6px; margin-top: 1rem; white-space: pre; }
.radio-specs .spec-item { min-width: 0; flex-wrap: wrap; gap: 0.4rem; }
.radio-specs .value { min-width: 0; overflow-wrap: anywhere; }

.form-grid { display: flex; flex-direction: column; gap: 1.25rem; max-width: 800px; }
.form-grid label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--text-muted); }
.form-grid label.full-width { width: 100%; }
.form-grid.flight-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); max-width: none; align-items: end; margin-bottom: 1rem; }
.flight-filters label { min-width: 0; }
.flight-filters select { width: 100%; min-width: 0; }
.form-grid input, .form-grid select, .form-grid textarea {
    background: #0f172a; border: 1px solid var(--border); color: var(--text);
    padding: 0.55rem 0.7rem; border-radius: 6px; font-size: 0.95rem; font-family: inherit;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-grid fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.form-grid fieldset > label, .form-grid fieldset .battery-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; align-items: end; }
.form-grid legend { padding: 0 0.5rem; color: var(--accent); font-size: 0.9rem; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.checkbox-label input { width: auto; }
.form-grid label.disabled-label { display: flex; justify-content: flex-start; align-self: flex-start; }
.battery-row { border-bottom: 1px dashed var(--border); padding-bottom: 0.75rem; }
.form-actions { display: flex; gap: 0.75rem; }
.notice { background: #450a0a; border: 1px solid #991b1b; color: #fecaca; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.success-notice { background: #052e16; border: 1px solid #166534; color: #bbf7d0; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.inline-link { font-size: 0.8rem; color: var(--accent); text-decoration: none; align-self: flex-start; }

.settings-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.settings-link { display: block; background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; text-decoration: none; color: var(--text); }
.settings-link:hover { border-color: var(--accent); }
.settings-link h3 { color: var(--accent); margin-bottom: 0.4rem; font-size: 1rem; }
.settings-link p { color: var(--text-muted); font-size: 0.85rem; }

.image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 260px)); gap: 1rem; }
.image-gallery-item { background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; align-items: center; padding: 0.5rem; }
.image-gallery-item img { max-width: 250px; max-height: 250px; width: auto; height: auto; object-fit: contain; display: block; }
.image-gallery-item figcaption { padding: 0.4rem 0.6rem; text-align: right; font-size: 0.8rem; width: 100%; display: flex; justify-content: flex-end; gap: 0.6rem; }
.icon-badge { color: var(--accent-green); font-size: 0.8rem; }

.aircraft-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; display: block; }
.aircraft-thumb-placeholder { display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border); color: var(--text-muted); font-size: 1.1rem; }

.mobile-nav-checkbox, .mobile-nav-toggle { display: none; }
.mobile-nav-account { display: none; }
.is-mobile { padding: 0.75rem 0; overflow-x: hidden; }
.is-mobile .container { width: 100%; padding: 0 0.75rem; gap: 1rem; }
.is-mobile header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto) auto; align-items: center; gap: 0.5rem; padding-bottom: 0.75rem; }
.is-mobile header h1 { min-width: 0; grid-column: 1; grid-row: 1; }
.is-mobile .app-logo { max-width: min(42vw, 220px); max-height: 48px; }
.is-mobile .mobile-nav-checkbox { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; }
.is-mobile .mobile-nav-toggle { display: inline-flex; grid-column: 3; grid-row: 1; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); color: var(--text); font: inherit; font-weight: 600; }
.is-mobile .mobile-nav-checkbox:focus-visible + .mobile-nav-toggle { outline: 2px solid var(--accent); outline-offset: 2px; }
.is-mobile header nav { grid-column: 1 / -1; grid-row: 2; display: none; gap: 0.25rem; }
.is-mobile .mobile-nav-checkbox:checked ~ nav { display: grid; }
.is-mobile header nav a, .is-mobile .user-menu a { display: flex; align-items: center; min-height: 44px; padding: 0.55rem 0.65rem; border-radius: 6px; }
.is-mobile header nav a { background: rgba(30, 41, 59, 0.7); }
.is-mobile .user-menu { display: contents; }
.is-mobile .user-menu .muted { grid-column: 2; grid-row: 1; min-width: 0; max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
.is-mobile .user-menu > a, .is-mobile .user-menu > form { display: none; }
.is-mobile .mobile-nav-account { display: grid; gap: 0.25rem; margin-top: 0.35rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.is-mobile .mobile-nav-account form { margin: 0; }
.is-mobile .mobile-nav-account button { width: 100%; min-height: 44px; padding: 0.55rem 0.65rem; border: 0; border-radius: 6px; background: rgba(30, 41, 59, 0.7); color: var(--accent); font: inherit; text-align: left; cursor: pointer; }
.is-mobile main { gap: 1rem; min-width: 0; }
.is-mobile .card { min-width: 0; padding: 1rem; border-radius: 8px; }
.is-mobile .card-header { align-items: flex-start; }
.is-mobile .card-header > * { min-width: 0; }
.is-mobile .button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.is-mobile .form-grid { width: 100%; max-width: none; gap: 1rem; }
.is-mobile .form-grid input:not([type="checkbox"]), .is-mobile .form-grid select, .is-mobile .form-grid textarea { width: 100%; min-width: 0; min-height: 44px; }
.is-mobile .form-grid textarea { min-height: 96px; }
.is-mobile .form-grid input[type="checkbox"] { width: 24px; height: 24px; flex: 0 0 24px; }
.is-mobile .checkbox-label { min-height: 44px; }
.is-mobile .form-actions { flex-wrap: wrap; }
.is-mobile .form-actions > * { flex: 1 1 9rem; }
.is-mobile .form-grid fieldset { min-width: 0; padding: 0.75rem; }
.is-mobile .form-grid fieldset > label, .is-mobile .form-grid fieldset .battery-row { grid-template-columns: minmax(0, 1fr); }
.is-mobile .table-wrap { overflow: visible; }
.is-mobile table.data-table { display: block; width: 100%; min-width: 0; }
.is-mobile table.data-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.is-mobile table.data-table tbody { display: block; }
.is-mobile table.data-table tbody tr { display: grid; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.is-mobile table.data-table tbody td { display: grid; grid-template-columns: minmax(6.5rem, 36%) minmax(0, 1fr); gap: 0.5rem; min-width: 0; padding: 0.45rem 0.25rem; border: 0; overflow-wrap: anywhere; }
.is-mobile table.data-table tbody td::before { content: attr(data-label); color: var(--text-muted); font-size: 0.75rem; font-weight: 600; }
.is-mobile table.data-table tbody td:not([data-label]) { grid-template-columns: minmax(0, 1fr); }
.is-mobile .table-pagination { align-items: stretch; gap: 0.65rem; margin: 0.75rem 0; }
.is-mobile .table-pagination label, .is-mobile .page-navigation { flex-wrap: wrap; }
.is-mobile .table-pagination input { min-height: 44px; }
.is-mobile .page-navigation .button { min-width: 44px; min-height: 44px; }
.is-mobile .table-search-input { max-width: none; min-height: 44px; }
.is-mobile .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.is-mobile .stat-card { min-width: 0; padding: 0.75rem; }
.is-mobile .stat-card .value { overflow-wrap: anywhere; font-size: 1.1rem; }
.is-mobile .spec-grid { grid-template-columns: minmax(0, 1fr); }
.is-mobile .image-gallery { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.is-mobile .image-gallery-item img { max-width: 100%; }
.is-mobile .telemetry-labels > div { grid-template-columns: minmax(0, 1fr); }


@media (max-width: 640px) {
    body { padding: 1rem 0; }
 

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-wrap { width: 100%; max-width: 380px; }
.login-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.login-logo { max-width: 100%; max-height: 80px; align-self: center; }
.login-title { text-align: center; font-size: 1.3rem; }
.login-card .form-grid { max-width: none; }   header { flex-direction: column; align-items: flex-start; }
}

.site-body { min-height: 100vh; padding: 0; }
.site-shell { max-width: 1240px; min-height: 100vh; margin: 0 auto; padding: 1.5rem 2rem 1rem; display: flex; flex-direction: column; }
.site-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 470px); align-items: start; gap: 2rem; border-bottom: 1px solid var(--border); padding: 0 0 1.25rem; }
.site-heading { display: flex; flex-direction: column; align-items: flex-start; gap: 1.25rem; }
.site-brand { min-height: 52px; display: inline-flex; align-items: center; gap: 0.85rem; color: var(--text); text-decoration: none; font-size: 1.25rem; font-weight: 700; }
.site-logo { max-width: 270px; max-height: 84px; width: auto; height: auto; object-fit: contain; }
.site-nav { display: flex; flex-wrap: wrap; column-gap: 0.5rem; row-gap: 0.5rem; }
.site-nav a { display: inline-block; padding: 0.35rem 0.6rem; }
.site-nav a, .site-footer a { color: var(--text-muted); text-decoration: none; }
.site-nav a:hover, .site-footer a:hover { color: var(--accent); }
.site-account { min-width: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; }
.site-login-form { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 0.6rem; }
.site-login-form label:not(.site-remember) { min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; color: var(--text-muted); font-size: 0.75rem; }
.site-login-form input[type="email"], .site-login-form input[type="password"] { width: 100%; min-width: 0; height: 38px; padding: 0.5rem 0.6rem; background: #0f172a; border: 1px solid var(--border); border-radius: 6px; color: var(--text); font: inherit; }
.site-login-form .button { height: 38px; white-space: nowrap; }
.site-remember { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-size: 0.75rem; }
.site-login-error { color: #fecaca; font-size: 0.8rem; }
.site-main { flex: 1; }
.site-intro { padding: 3.5rem 0 2.5rem; border-bottom: 1px solid var(--border); }
.site-kicker { margin-bottom: 0.8rem; color: var(--accent-green); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; }
.site-intro h1 { max-width: 760px; margin-bottom: 0.7rem; font-size: 2.35rem; line-height: 1.12; }
.site-intro > p:last-child { color: var(--text-muted); font-size: 1.05rem; }
.site-feed { max-width: 850px; }
.site-post { padding: 2rem 0; border-bottom: 1px solid var(--border); }
.site-post-date { margin-bottom: 0.45rem; color: var(--accent); font-size: 0.78rem; }
.site-post h2 { margin-bottom: 0.7rem; font-size: 1.45rem; line-height: 1.3; }
.site-post-excerpt { margin-bottom: 0.8rem; color: #dbeafe; font-size: 1.02rem; font-weight: 600; line-height: 1.6; }
.site-post-body, .site-page-body { color: #d1d5db; line-height: 1.8; overflow-wrap: anywhere; }
.site-empty { padding: 2.5rem 0; color: var(--text-muted); }
.site-contact-note { color: var(--text-muted); }
.site-contact-form { display: grid; gap: 0.9rem; margin-top: 1.25rem; }
.site-contact-form label { display: grid; gap: 0.35rem; color: var(--text-muted); font-size: 0.85rem; }
.site-contact-form input, .site-contact-form textarea { width: 100%; min-width: 0; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: #0f172a; color: var(--text); font: inherit; }
.site-contact-form textarea { resize: vertical; }
.site-contact-form button { justify-self: start; }
.site-contact-note { margin: 0; font-size: 0.78rem; }
.site-contact-status { color: var(--accent-green); }
.site-contact-honey { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.site-pagination { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.5rem 0; color: var(--text-muted); font-size: 0.85rem; }
.site-pagination a { color: var(--accent); text-decoration: none; }
.site-footer { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center; padding: 1.25rem 0 0; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.8rem; }
.site-footer span { margin-right: auto; }
.app-contact-footer { padding: 0.85rem 0; border-top: 1px solid var(--border); text-align: right; }
.app-contact-footer a { color: var(--text-muted); }
.site-page-header { display: flex; justify-content: space-between; align-items: center; gap: 2rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.site-page { width: 100%; max-width: 780px; flex: 1; padding: 3rem 0; }
.site-page h1 { margin-bottom: 1.5rem; font-size: 2rem; }
.site-page-body { margin-bottom: 1.75rem; }

@media (max-width: 820px) {
    .site-header { grid-template-columns: 1fr; gap: 1.5rem; }
    .site-account { align-items: stretch; }
    .site-login-form { max-width: 600px; }
    .site-page-header { align-items: flex-start; flex-direction: column; gap: 1rem; }
}

@media (max-width: 560px) {
    .site-shell { padding: 1rem; }
    .site-login-form { grid-template-columns: 1fr 1fr; }
    .site-login-form .button { grid-column: 1 / -1; }
    .site-intro { padding: 2.5rem 0 1.75rem; }
    .site-intro h1 { font-size: 2rem; }
    .site-footer { gap: 0.8rem; }
    .site-footer span { width: 100%; }
}
