:root {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: #111827;
    --panel-2: #172033;
    --panel-3: #1f2937;
    --border: #334155;
    --border-soft: #253247;
    --text: #f8fafc;
    --muted: #94a3b8;
    --muted-2: #cbd5e1;
    --blue: #2563eb;
    --blue-hover: #1d4ed8;
    --red: #ef4444;
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --radius: 14px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

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

a { color: #93c5fd; }

button, input, select, textarea { font: inherit; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(15, 23, 42, 0.96);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(10px);
}

.site-header-inner,
.site-footer-inner,
.page-shell {
    width: min(1500px, calc(100% - 40px));
    margin: 0 auto;
}

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

.brand-block { min-width: 0; }

.site-title {
    color: var(--text);
    font-size: 20px;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.site-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.nav-link,
.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--panel-3);
    color: var(--text);
    text-decoration: none;
    font-weight: 650;
    cursor: pointer;
}

.nav-link:hover,
.button:hover,
button.button:hover { background: #334155; }

.nav-link.active {
    background: #1e3a8a;
    border-color: #3b82f6;
}

.button-primary,
button.button-primary {
    background: var(--blue);
    border-color: var(--blue);
}

.button-primary:hover,
button.button-primary:hover { background: var(--blue-hover); }

.button-danger,
button.button-danger { background: #7f1d1d; }

.button-small,
button.button-small {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
}

.page-shell { padding: 28px 0 48px; }

.site-footer {
    border-top: 1px solid var(--border-soft);
    color: var(--muted);
}

.site-footer-inner {
    padding: 18px 0 28px;
    font-size: 12px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 38px);
}

.page-heading .description {
    margin-top: 7px;
    color: var(--muted);
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13);
    padding: 22px;
    margin-bottom: 20px;
}

.card h2,
.card h3 { margin-top: 0; }

.notice,
.error,
.warning,
.success {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
}

.error { background: #3f151b; border-color: #7f1d1d; color: #fecaca; }
.warning { background: #3b2f0d; border-color: #854d0e; color: #fde68a; }
.success { background: #12351f; border-color: #166534; color: #bbf7d0; }
.notice { background: #172554; border-color: #1e40af; color: #bfdbfe; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
}

.inventory-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.inventory-table th,
.inventory-table td {
    padding: 12px 13px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}

.inventory-table th {
    color: var(--muted-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #111c2e;
}

.inventory-table tbody tr:last-child td { border-bottom: 0; }

.inventory-table tbody tr[data-preview-device-id] { cursor: pointer; }
.inventory-table tbody tr[data-preview-device-id]:hover { background: #17233a; }
.inventory-table tbody tr[data-preview-device-id]:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: -2px;
}

.device-photo-thumb {
    width: 92px;
    height: 68px;
    border-radius: 9px;
    object-fit: cover;
    display: block;
    background: #020617;
    border: 1px solid var(--border);
}

.photo-placeholder {
    width: 92px;
    height: 68px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: #0b1220;
    border: 1px dashed var(--border);
    color: var(--muted);
    font-size: 12px;
}

.primary-text { font-weight: 700; color: var(--text); }
.secondary-text { margin-top: 3px; color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #334155;
    color: #e2e8f0;
}

.badge-working { background: #14532d; color: #bbf7d0; }
.badge-broken { background: #7f1d1d; color: #fecaca; }
.badge-partially_working,
.badge-needs_test { background: #713f12; color: #fef3c7; }
.badge-repair { background: #7c2d12; color: #ffedd5; }
.badge-in_use { background: #1e3a8a; color: #dbeafe; }

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

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

label.field-label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted-2);
    font-weight: 650;
}

input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #475569;
    border-radius: 9px;
    background: #0b1220;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

textarea { min-height: 130px; resize: vertical; }

.help {
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.inline-field-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    align-items: end;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.upload-area {
    padding: 16px;
    border: 1px dashed #475569;
    border-radius: 10px;
    background: #0b1220;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.photo-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #0b1220;
}

.photo-card img {
    width: 100%;
    height: 145px;
    object-fit: cover;
    display: block;
    background: #020617;
}

.photo-card-body { padding: 12px; }
.photo-meta { margin-top: 6px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.primary-selector { display: flex; align-items: center; gap: 8px; font-weight: 700; }

.prompt-textarea { min-height: 430px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.json-textarea { min-height: 280px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.step-label { color: #93c5fd; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.instructions { color: var(--muted-2); line-height: 1.7; }

