/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-bg:   #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active:#e2e8f0;
    --accent:       #3b82f6;
    --accent-dark:  #2563eb;
    --bg:           #f1f5f9;
    --surface:      #ffffff;
    --border:       #e2e8f0;
    --text:         #1e293b;
    --text-muted:   #64748b;
    --danger:       #ef4444;
    --success:      #22c55e;
    --warning:      #f59e0b;
    --radius:       6px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace; font-size: 13px; }

/* ── Shell layout ──────────────────────────────────────────────────────── */
.shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand:hover { text-decoration: none; color: #ffffff; }

.brand-hex {
    width: 30px;
    height: 30px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.brand-name { letter-spacing: .02em; }

.nav-list {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.nav-link {
    display: block;
    padding: 8px 16px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    border-radius: 0;
    transition: color .15s, background .15s;
    text-decoration: none;
}
.nav-link:hover { color: var(--sidebar-active); background: rgba(255,255,255,.05); text-decoration: none; }
.nav-link.active { color: #ffffff; background: rgba(59,130,246,.3); border-right: 2px solid var(--accent); }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-meta {
    font-size: 11px;
    color: #475569;
    text-decoration: none;
}
.sidebar-meta:hover { color: var(--sidebar-text); }

/* ── Main content ──────────────────────────────────────────────────────── */
.main {
    flex: 1;
    overflow-x: hidden;
}

.main-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 28px;
}

/* ── Page header ───────────────────────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.page-header .subtitle {
    color: var(--text-muted);
    margin-top: 4px;
}
.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}
.page-actions h1 {
    font-size: 22px;
    font-weight: 700;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}
.card h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

/* Dashboard grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.dash-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(59,130,246,.12);
    text-decoration: none;
    color: var(--text);
}
.dash-card-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}
.dash-card-body h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.dash-card-body p  { font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
thead th {
    background: #f8fafc;
    text-align: left;
    padding: 9px 12px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f1f5f9; text-decoration: none; color: var(--text); }
.btn-secondary.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid.one-col { grid-template-columns: 1fr; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

input[type=text],
input[type=url],
input[type=number],
input[type=email],
input[type=password],
textarea,
select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s;
    outline: none;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
textarea { resize: vertical; min-height: 100px; }

.form-hint { font-size: 11.5px; color: var(--text-muted); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ── Array field groups ─────────────────────────────────────────────────── */
.array-section { margin-bottom: 20px; }
.array-section h4 {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 10px;
}
.array-row {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.array-row-actions { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ── Detail view ────────────────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 3px; }
.detail-field p { font-size: 13.5px; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 500;
    margin: 2px;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 500;
}
.status-active   { background: #dcfce7; color: #166534; }
.status-inactive { background: #fee2e2; color: #991b1b; }
.status-archived { background: #f1f5f9; color: #475569; }

/* ── Markdown rendered content ──────────────────────────────────────────── */
.md-content { line-height: 1.7; }
.md-content h1 { font-size: 20px; margin: 16px 0 8px; }
.md-content h2 { font-size: 17px; margin: 14px 0 6px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.md-content h3 { font-size: 15px; margin: 12px 0 4px; }
.md-content p  { margin-bottom: 10px; }
.md-content ul, .md-content ol { padding-left: 20px; margin-bottom: 10px; }
.md-content li { margin-bottom: 4px; }
.md-content code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }
.md-content pre { background: #1e293b; color: #e2e8f0; padding: 14px 16px; border-radius: 6px; overflow-x: auto; margin-bottom: 12px; }
.md-content pre code { background: none; padding: 0; color: inherit; }
.md-content blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); margin: 10px 0; }
.md-content table { margin-bottom: 12px; }

/* ── Alerts / info bars ─────────────────────────────────────────────────── */
.info-bar {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    color: #1d4ed8;
    margin-top: 20px;
}
.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state h2 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.empty-state p  { margin-bottom: 16px; }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 10px;
    margin-top: 20px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.location-card, .access-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 13px;
}
.location-card strong, .access-card strong { display: block; margin-bottom: 4px; }
.location-card code { font-size: 12px; word-break: break-all; }
