:root {
    --bg: #0c0e12;
    --surface: #12151b;
    --surface-2: #181c24;
    --line: #272c36;
    --line-soft: #1d222b;
    --text: #f3f5f7;
    --muted: #8b93a1;
    --accent: #c7ff4a;
    --accent-soft: rgba(199, 255, 74, .1);
    --danger: #ff6b6b;
    --success: #62e6a7;
    --shadow: 0 24px 70px rgba(0, 0, 0, .34);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #0f1116; }
.brand { height: 78px; display: flex; align-items: center; gap: 11px; padding: 0 22px; font-size: 14px; font-weight: 850; letter-spacing: .16em; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: var(--accent); color: #11150a; font-weight: 950; letter-spacing: 0; box-shadow: 0 0 28px rgba(199, 255, 74, .12); }
.primary-nav { display: grid; gap: 4px; padding: 10px 12px 22px; border-bottom: 1px solid var(--line-soft); }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; transition: .16s ease; }
.nav-item span { width: 19px; color: #69717f; text-align: center; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--text); background: #1b2028; box-shadow: inset 2px 0 var(--accent); }
.sidebar-section { min-height: 0; flex: 1; padding: 22px 13px; overflow-y: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.database-list { display: grid; gap: 3px; }
.database-item { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px; border: 0; border-radius: 8px; background: transparent; color: #b8bec8; cursor: pointer; text-align: left; }
.database-item::before { content: ''; width: 7px; height: 7px; margin-right: 10px; border: 1px solid #606878; border-radius: 50%; }
.database-item span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.database-item small { color: #59616e; }
.database-item:hover, .database-item.active { background: var(--surface-2); color: var(--text); }
.database-item.active::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 9px rgba(199, 255, 74, .5); }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 17px; border-top: 1px solid var(--line); }
.user-chip { min-width: 0; display: flex; align-items: center; gap: 10px; }
.user-chip div { min-width: 0; display: grid; }
.user-chip strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; }
.user-chip small { color: var(--muted); font-size: 10px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #39404d; border-radius: 50%; background: var(--surface-2); font-size: 11px; font-weight: 800; }

.main-content { min-width: 0; padding: 0 34px 40px; }
.topbar { min-height: 108px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line-soft); }
.topbar h1 { margin: 0; font-size: 25px; font-weight: 650; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: #aab1bc; font-size: 11px; }
.pulse { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(98, 230, 167, .09), 0 0 12px rgba(98, 230, 167, .45); }

.button, .icon-button { border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; transition: .16s ease; }
.button { min-height: 37px; padding: 0 15px; border-radius: 8px; color: #d8dce3; font-size: 12px; font-weight: 650; }
.button:hover:not(:disabled) { border-color: #414957; background: #202630; transform: translateY(-1px); }
.button:disabled { opacity: .4; cursor: not-allowed; }
.button-primary { border-color: var(--accent); background: var(--accent); color: #11150a; }
.button-primary:hover:not(:disabled) { border-color: #dbff8b; background: #dbff8b; }
.button-small { min-height: 32px; padding: 0 11px; }
.button-wide { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 17px; }
.icon-button { width: 29px; height: 29px; display: grid; place-items: center; padding: 0; border-radius: 7px; color: #a9b0bb; }
.icon-button:hover { border-color: #434b59; color: var(--text); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 25px 0 16px; }
.metric-card { min-height: 124px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.metric-card > span { color: var(--muted); font-size: 11px; }
.metric-card strong { font-size: 31px; font-weight: 620; letter-spacing: -.04em; }
.metric-card small { color: #606875; font-size: 10px; }
.metric-card.accent { border-color: rgba(199, 255, 74, .3); background: linear-gradient(145deg, rgba(199, 255, 74, .1), var(--surface) 65%); }
.metric-card.accent strong { color: var(--accent); }

.workspace-grid { display: grid; grid-template-columns: minmax(245px, .68fr) minmax(520px, 1.8fr); gap: 12px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); overflow: hidden; }
.panel-header { min-height: 75px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.panel-header h2 { margin: 0; font-size: 15px; font-weight: 630; }
.panel-actions { display: flex; align-items: center; gap: 7px; }
.collection-panel { min-height: 470px; }
.collection-list { display: grid; align-content: start; gap: 2px; padding: 8px; }
.collection-item { display: flex; align-items: center; justify-content: space-between; padding: 13px 11px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.collection-item div { display: grid; gap: 4px; }
.collection-item strong { font-size: 12px; font-weight: 650; }
.collection-item small { color: var(--muted); font-size: 10px; }
.collection-item > span { color: #555e6b; }
.collection-item:hover, .collection-item.active { background: var(--surface-2); }
.collection-item.active strong { color: var(--accent); }
.empty-state { min-height: 330px; place-content: center; justify-items: center; padding: 35px; text-align: center; }
.empty-state h3 { margin: 12px 0 5px; font-size: 13px; }
.empty-state p { max-width: 230px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.empty-icon { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--accent); }
.records-header { align-items: flex-end; }
.record-actions { display: flex; gap: 8px; }
.search-input { width: 190px; min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #0f1217; color: var(--text); font-size: 11px; }
.search-input:focus { border-color: #586271; }
.search-input:disabled { opacity: .45; }
.table-wrap { min-height: 394px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); color: #666f7d; font-size: 9px; font-weight: 750; letter-spacing: .11em; text-align: left; text-transform: uppercase; }
td { max-width: 270px; padding: 13px 14px; border-bottom: 1px solid var(--line-soft); color: #bbc1ca; font-size: 11px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(255,255,255,.018); }
td code { color: var(--accent); font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.json-preview { display: block; overflow: hidden; color: #737c89; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.version-badge { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; color: #8f97a3; font-size: 9px; }
.table-empty { height: 280px; color: #626a77; text-align: center; cursor: default; }

.audit-list { display: grid; padding: 7px 18px 20px; }
.audit-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line-soft); }
.audit-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #5d6673; }
.audit-item:first-child .audit-dot { background: var(--accent); box-shadow: 0 0 9px rgba(199, 255, 74, .3); }
.audit-item strong { display: block; margin-bottom: 4px; font-size: 11px; }
.audit-item p { margin: 0; color: var(--muted); font-size: 11px; }
.audit-item time { color: #5f6774; font-size: 9px; }

.health-hero { min-height: 150px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 25px 0 14px; padding: 25px 28px; border: 1px solid rgba(199, 255, 74, .22); border-radius: 12px; background: radial-gradient(circle at 85% 20%, rgba(199,255,74,.11), transparent 34%), var(--surface); }
.health-hero h2 { margin: 0 0 8px; font-size: 25px; font-weight: 620; letter-spacing: -.03em; }
.health-hero p:last-child { margin: 0; color: var(--muted); font-size: 11px; }
.health-state { display: flex; align-items: center; gap: 9px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 700; }
.health-state.down { border-color: rgba(255,107,107,.4); color: var(--danger); }
.health-state.down .pulse { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,107,107,.09); }
.health-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.health-card { min-height: 175px; padding: 19px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.health-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.health-card-header strong { font-size: 13px; text-transform: capitalize; }
.health-badge { padding: 4px 7px; border-radius: 999px; background: rgba(98,230,167,.09); color: var(--success); font-size: 9px; font-weight: 800; }
.health-badge.down { background: rgba(255,107,107,.09); color: var(--danger); }
.health-detail { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 10px; }
.health-detail span:last-child { max-width: 65%; overflow: hidden; color: #c0c6cf; text-align: right; text-overflow: ellipsis; white-space: nowrap; }

.modal { width: min(460px, calc(100vw - 30px)); padding: 0; border: 1px solid #333a46; border-radius: 13px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(4, 5, 7, .74); backdrop-filter: blur(5px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 17px; }
#modal-fields { display: grid; gap: 15px; padding: 21px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 20px; border-top: 1px solid var(--line); }
.credential-modal { width: min(590px, calc(100vw - 30px)); }
.credential-body { display: grid; gap: 15px; max-height: 62vh; padding: 20px; overflow-y: auto; }
.issued-secret { display: grid; gap: 12px; padding: 16px; border: 1px solid rgba(199,255,74,.3); border-radius: 10px; background: var(--accent-soft); }
.secret-warning { display: grid; gap: 3px; }
.secret-warning strong { color: var(--accent); font-size: 12px; }
.secret-warning span { color: #a8b092; font-size: 10px; }
.issued-secret input { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.credential-list { display: grid; gap: 7px; }
.credential-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line-soft); border-radius: 8px; background: #101319; }
.credential-item.revoked { opacity: .5; }
.credential-item > div { min-width: 0; display: grid; gap: 4px; }
.credential-item code { overflow: hidden; color: #d7dce4; font-size: 10px; text-overflow: ellipsis; }
.credential-item small { color: var(--muted); font-size: 9px; }
label { display: grid; gap: 7px; color: #929aa6; font-size: 10px; font-weight: 650; letter-spacing: .04em; }
label input, label textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #0d1015; color: var(--text); }
label input:focus, label textarea:focus { border-color: #586272; box-shadow: 0 0 0 3px rgba(120, 133, 150, .08); }
.field-help { margin: -3px 0 0; color: #626a77; font-size: 10px; }

.drawer { position: fixed; z-index: 30; top: 0; right: 0; width: min(560px, 100vw); height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; border-left: 1px solid #343b46; background: #101319; box-shadow: -24px 0 70px rgba(0, 0, 0, .35); transform: translateX(102%); transition: transform .22s ease; }
.drawer.open { transform: translateX(0); }
.drawer-header, .drawer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: 0; font-size: 17px; }
.drawer-body { display: grid; align-content: start; gap: 17px; padding: 20px; overflow-y: auto; }
.drawer-body textarea { min-height: 330px; resize: vertical; color: #d4d8df; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.drawer-footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.json-status { margin-top: -11px; color: var(--success); font-size: 10px; }
.json-status.invalid { color: var(--danger); }
.revision-section { border-top: 1px solid var(--line); padding-top: 15px; }
.revision-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border-bottom: 1px solid var(--line-soft); }
.revision-item div { display: grid; gap: 3px; }
.revision-item strong { font-size: 10px; }
.revision-item small { color: var(--muted); font-size: 9px; }
.scrim { position: fixed; z-index: 20; inset: 0; background: rgba(4, 5, 7, .66); backdrop-filter: blur(2px); }
.toast-stack { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 260px; padding: 13px 15px; border: 1px solid #38404c; border-radius: 9px; background: #191e26; box-shadow: var(--shadow); font-size: 11px; animation: toast-in .2s ease; }
.toast.error { border-color: rgba(255, 107, 107, .45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.skeleton-line { height: 33px; border-radius: 7px; background: linear-gradient(90deg, #171b22, #20252e, #171b22); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton-line.short { width: 72%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.login-page { overflow: hidden; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.2fr minmax(430px, .8fr); background: radial-gradient(circle at 20% 20%, rgba(199,255,74,.07), transparent 28%), var(--bg); }
.login-aside { min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; padding: 24px 42px 38px; border-right: 1px solid var(--line); position: relative; overflow: hidden; }
.login-aside::after { content: ''; position: absolute; width: 520px; height: 520px; right: -200px; bottom: -250px; border: 1px solid rgba(199,255,74,.08); border-radius: 50%; box-shadow: 0 0 0 70px rgba(199,255,74,.025), 0 0 0 140px rgba(199,255,74,.015); }
.brand-large { height: auto; padding: 0; }
.login-copy { position: relative; z-index: 1; max-width: 650px; }
.login-copy h1 { margin: 0 0 20px; font-size: clamp(48px, 6.2vw, 88px); font-weight: 540; letter-spacing: -.065em; line-height: .94; }
.login-copy h1 span { color: var(--accent); }
.login-copy > p:last-child { max-width: 490px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.signal-card { position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; width: fit-content; padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; background: rgba(18, 21, 27, .78); }
.signal-card div { display: grid; gap: 2px; }
.signal-card strong { font-size: 11px; }
.signal-card small { color: var(--muted); font-size: 9px; }
.login-panel { display: grid; place-items: center; padding: 38px; background: #0f1116; }
.login-form { width: min(360px, 100%); display: grid; gap: 19px; }
.login-form h2 { margin: 0 0 7px; font-size: 30px; font-weight: 600; letter-spacing: -.04em; }
.login-form label { font-size: 11px; }
.login-form label input { min-height: 45px; }
.login-note { margin: 0; color: #59616e; font-size: 9px; line-height: 1.6; text-align: center; }
.alert { padding: 10px 12px; border: 1px solid; border-radius: 8px; font-size: 10px; }
.alert-error { border-color: rgba(255,107,107,.35); background: rgba(255,107,107,.07); color: #ff9292; }
.alert-success { border-color: rgba(98,230,167,.3); background: rgba(98,230,167,.06); color: var(--success); }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .workspace-grid { grid-template-columns: 1fr; }
    .collection-panel { min-height: 300px; }
    .empty-state { min-height: 210px; }
    .health-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
    .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
    .sidebar { align-items: center; }
    .brand { padding: 0; }
    .brand > span:last-child, .nav-item:not(.active), .nav-item.active { font-size: 0; }
    .nav-item span { font-size: 15px; }
    .sidebar-section, .sidebar-footer .user-chip { display: none; }
    .sidebar-footer { margin-top: auto; }
    .main-content { padding: 0 16px 25px; }
    .topbar { min-height: 90px; }
    .topbar-actions .status-pill { display: none; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .record-actions { align-items: stretch; flex-direction: column; }
    .search-input { width: 160px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .login-panel { min-height: 100vh; }
    .health-grid { grid-template-columns: 1fr; }
}
