/* Panel: neutral base; --brand (set per account in the layout) is the only accent. */
:root {
    --brand: #2563eb;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e3e6ea;
    --text: #1f2933;
    --muted: #6b7480;
    --ok: #15803d;
    --ok-bg: #ecfdf3;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --error: #b91c1c;
    --error-bg: #fef2f2;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 20px 14px;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; min-height: 44px; margin: 0 8px 24px; }
.brand img { max-height: 44px; max-width: 100%; }
.brand-name { font-weight: 700; font-size: 18px; color: var(--text); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    color: var(--text); padding: 8px 10px; border-radius: 8px; font-weight: 500;
}
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.whoami { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.whoami-name { font-weight: 600; overflow-wrap: anywhere; }
.whoami-role { color: var(--muted); margin-bottom: 6px; }
.main { padding: 28px 32px; max-width: 1200px; width: 100%; min-width: 0; }

@media (max-width: 800px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; min-width: 0; }
    .whoami button.link { white-space: nowrap; font-size: 13px; }
    .brand { margin: 0 12px 0 0; min-height: 32px; }
    .brand img { max-height: 32px; }
    .sidebar nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; min-width: 0; }
    .whoami { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; gap: 10px; align-items: center; }
    .whoami-role { display: none; }
    .whoami-name { display: none; }
    .whoami form { margin: 0; }
    .main { padding: 20px 16px; }
}

/* Surfaces */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-header h2 { margin: 0; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.muted { color: var(--muted); }
.list { margin: 0; padding-left: 18px; }
.list li { margin: 4px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; display: flex; flex-direction: column; color: var(--text);
}
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-weight: 600; }
.stat-detail { color: var(--muted); font-size: 13px; }
.stat-warn .stat-value { color: var(--warn); }
.stat-error .stat-value { color: var(--error); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.truncate { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Badges */
.tag, .badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: var(--bg); border: 1px solid var(--border); color: var(--text); white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-error { background: var(--error-bg); color: var(--error); border-color: transparent; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--error-bg); color: var(--error); }

/* Forms */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 560px; }
.form > * { min-width: 0; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-inline label { flex: 1 1 160px; }
label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; font-weight: 500; font-size: 14px; min-width: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=url], select, textarea {
    font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; width: 100%; color: var(--text);
}
input[type=file] { max-width: 100%; font: inherit; font-size: 13px; }
input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; }
.field-error { color: var(--error); font-size: 13px; font-weight: 500; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(.95); }
.btn-danger { color: var(--error); }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; background: var(--bg); }

.dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; } .dl dd { margin-bottom: 8px; } }

pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 480px; white-space: pre-wrap; word-break: break-word; }

.pagination { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--brand);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px;
}
.login-card h1 { margin-bottom: 4px; }
.login-card .form { margin-top: 20px; }

.logo-preview { max-height: 64px; max-width: 240px; padding: 8px; border: 1px dashed var(--border); border-radius: 8px; background: #fff; }
