@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ============================================
   PACS — Physical Access Control System
   Design language: Industrial Precision
   Ref: Linear / Vercel / Raycast stripped bare
   ============================================ */

:root {
    --ink:        #0a0a0b;
    --ink-2:      #1c1c1f;
    --ink-3:      #2a2a2e;
    --line:       #e4e4e7;
    --line-2:     #d1d1d6;
    --muted:      #8c8c99;
    --muted-2:    #b0b0bc;
    --surface:    #ffffff;
    --surface-2:  #f7f7f8;
    --surface-3:  #f0f0f2;
    --accent:     #0a0a0b;
    --accent-inv: #ffffff;
    --ok:         #16a34a;
    --ok-bg:      #f0fdf4;
    --ok-line:    #bbf7d0;
    --err:        #dc2626;
    --err-bg:     #fef2f2;
    --err-line:   #fecaca;
    --warn:       #ca8a04;
    --warn-bg:    #fefce8;
    --warn-line:  #fef08a;
    --info:       #2563eb;
    --info-bg:    #eff6ff;
    --info-line:  #bfdbfe;
    --sidebar-w:  220px;
    --header-h:   56px;
    --mono:       'DM Mono', 'SF Mono', 'Fira Code', monospace;
    --sans:       'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius:     6px;
    --radius-lg:  10px;
    --t:          150ms cubic-bezier(.4,0,.2,1);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    font-weight: 400;
    background: var(--surface-2);
    color: var(--ink);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Selection ─────────────────────────────── */
::selection { background: var(--ink); color: var(--surface); }

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid var(--line);
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: var(--ink);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.brand-text h2 {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .08em;
    color: var(--ink);
}

.brand-text p {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .03em;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 8px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    color: var(--muted);
    text-decoration: none;
    border-radius: var(--radius);
    transition: color var(--t), background var(--t);
    cursor: pointer;
    font-size: 13.5px;
    letter-spacing: -.01em;
    position: relative;
}

.nav-item:hover {
    color: var(--ink);
    background: var(--surface-3);
}

.nav-item.active {
    color: var(--ink);
    background: var(--surface-3);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 14px;
    background: var(--ink);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    font-size: 15px;
    opacity: .6;
    flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--line);
}

.server-status-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--surface-2);
}

/* ============================================
   Main
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

#page-title {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -.01em;
    color: var(--ink);
}

.breadcrumb-sep {
    color: var(--line-2);
    font-size: 16px;
    font-weight: 300;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-family: var(--mono);
    color: var(--muted);
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 99px;
    letter-spacing: .02em;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online  { background: var(--ok);  box-shadow: 0 0 0 2px var(--ok-bg); }
.status-dot.offline { background: var(--err); box-shadow: 0 0 0 2px var(--err-bg); }

/* pulse only when online */
@keyframes pulse-dot {
    0%,100% { opacity: 1; }
    50%      { opacity: .4; }
}
.status-dot.online { animation: pulse-dot 2.4s ease infinite; }

/* ============================================
   Content
   ============================================ */

.content-container {
    flex: 1;
    padding: 28px;
    max-width: 1200px;
    width: 100%;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp .2s ease; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Cards
   ============================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 0;
}

@media (max-width: 1100px) { .card-grid { grid-template-columns: 1fr; } }

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.card-header h3 {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -.01em;
}

.card-header .card-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
}

/* ============================================
   Forms
   ============================================ */

.form-section { display: flex; flex-direction: column; gap: 16px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row-spaced { margin-bottom: 20px; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--muted);
}

.form-group input,
.form-group select {
    padding: 8px 11px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    font-size: 13.5px;
    font-family: var(--sans);
    transition: border-color var(--t), box-shadow var(--t);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c8c99' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-group input:hover,
.form-group select:hover { border-color: var(--line-2); }

.form-group input:focus,
.form-group select:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(10,10,11,.06);
}

.form-group input::placeholder { color: var(--muted-2); }

/* ============================================
   Buttons
   ============================================ */

.btn {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--sans);
    cursor: pointer;
    transition: all var(--t);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: -.01em;
    white-space: nowrap;
    background: var(--surface);
    color: var(--ink);
}

.btn:hover { background: var(--surface-3); border-color: var(--line-2); }
.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--ink);
    color: var(--accent-inv);
    border-color: var(--ink);
}
.btn-primary:hover {
    background: var(--ink-3);
    border-color: var(--ink-3);
    color: var(--accent-inv);
}

.btn-secondary { color: var(--muted); }
.btn-secondary:hover { color: var(--ink); }

.btn-info {
    background: var(--info-bg);
    color: var(--info);
    border-color: var(--info-line);
}
.btn-info:hover { background: #dbeafe; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ============================================
   Gate Tier Selection
   ============================================ */

.gate-section {
    margin-bottom: 20px;
}

.gate-section h4 {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

.tier-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tier-btn {
    padding: 14px 16px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--t);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-family: var(--sans);
    text-align: left;
}

.tier-btn:hover {
    border-color: var(--line-2);
    color: var(--ink);
    background: var(--surface-2);
}

.tier-btn.active {
    border-color: var(--ink);
    background: var(--surface);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink);
}

.tier-icon { font-size: 18px; flex-shrink: 0; }

.tier-label {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
}

.tier-label small {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--muted);
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

.tier-btn.active .tier-label small { color: var(--muted-2); }

/* ============================================
   Direction Buttons
   ============================================ */

.direction-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.direction-btn {
    padding: 10px 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--t);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--sans);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.direction-btn:hover { border-color: var(--line-2); color: var(--ink); }

.direction-btn.active.in {
    border-color: var(--ok);
    background: var(--ok-bg);
    color: var(--ok);
    box-shadow: inset 0 0 0 1px var(--ok-line);
}

.direction-btn.active.out {
    border-color: var(--warn);
    background: var(--warn-bg);
    color: var(--warn);
    box-shadow: inset 0 0 0 1px var(--warn-line);
}

.btn-icon { font-size: 14px; }

/* ============================================
   Swipe Response
   ============================================ */

.response-card { display: flex; flex-direction: column; }

.animation-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 180px;
    padding: 24px;
}

.swipe-status {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.swipe-status p {
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: -.01em;
}

.swipe-status.idle p   { color: var(--muted); }
.swipe-status.success p { color: var(--ok); }
.swipe-status.fail p    { color: var(--err); }

.status-icon { font-size: 36px; }

/* Idle animation */
.idle-indicator {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-2);
    font-size: 20px;
    position: relative;
}

.idle-indicator::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px dashed var(--line);
    animation: spin 12s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Checkmark */
.checkmark-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn .25s ease;
}

.checkmark-circle .background {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--ok-bg);
    border: 1.5px solid var(--ok-line);
    animation: scaleIn .25s ease;
}

.checkmark {
    width: 14px;
    height: 22px;
    border-right: 2px solid var(--ok);
    border-bottom: 2px solid var(--ok);
    position: relative;
    top: -2px;
    opacity: 0;
    transform: rotate(45deg);
    z-index: 1;
}

.checkmark.draw { animation: drawCheck .35s .15s ease forwards; }

/* Cross */
.cross-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn .25s ease;
}

.cross-circle .background {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--err-bg);
    border: 1.5px solid var(--err-line);
    animation: scaleIn .25s ease;
}

.cross {
    width: 22px;
    height: 22px;
    position: relative;
    z-index: 1;
}

.cross::before, .cross::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--err);
    top: 50%;
    left: 0;
    transform: translateY(-50%) rotate(45deg);
    opacity: 0;
}

.cross::after { transform: translateY(-50%) rotate(-45deg); }
.cross.draw::before, .cross.draw::after { animation: drawCross .25s .15s ease forwards; }

@keyframes scaleIn {
    from { transform: scale(.6); opacity: 0; }
    to   { transform: scale(1);  opacity: 1; }
}

@keyframes drawCheck {
    0%   { height: 0;    width: 0;    opacity: 1; }
    40%  { height: 0;    width: 14px; opacity: 1; }
    100% { height: 22px; width: 14px; opacity: 1; }
}

@keyframes drawCross {
    from { width: 0; opacity: 1; }
    to   { width: 100%; opacity: 1; }
}

/* ============================================
   Response Box
   ============================================ */

.response-box {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

/* ============================================
   Filter Section
   ============================================ */

.filter-section {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
    align-items: flex-end;
    flex-wrap: wrap;
}

/* ============================================
   Period Selector
   ============================================ */

.period-type-selector {
    display: flex;
    gap: 2px;
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 3px;
}

.period-btn {
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    font-family: var(--sans);
    cursor: pointer;
    transition: all var(--t);
    letter-spacing: .01em;
}

.period-btn:hover { color: var(--ink); }

.period-btn.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 .5px var(--line);
}

/* ============================================
   Mode Selector
   ============================================ */

.mode-selector {
    display: flex;
    gap: 8px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
    transition: all var(--t);
    background: var(--surface);
    user-select: none;
}

.mode-option:hover { color: var(--ink); border-color: var(--line-2); }

.mode-option input[type="radio"] {
    accent-color: var(--ink);
    width: 13px;
    height: 13px;
    cursor: pointer;
}

.mode-option:has(input:checked) {
    border-color: var(--ink);
    color: var(--ink);
    font-weight: 500;
    box-shadow: inset 0 0 0 1px var(--ink);
}

/* ============================================
   Stats Grid
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.stat-item {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color var(--t);
}

.stat-item:hover { border-color: var(--line-2); }

.stat-item-value {
    font-size: 22px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -.03em;
    font-family: var(--mono);
    line-height: 1.2;
}

.stat-item-label {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    letter-spacing: .02em;
}

/* ============================================
   Table
   ============================================ */

.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table thead {
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.table tbody tr {
    border-bottom: 1px solid var(--line);
    transition: background var(--t);
}

.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.empty:hover { background: transparent; }

.table td {
    padding: 11px 16px;
    color: var(--ink);
    vertical-align: middle;
}

.table td strong { font-weight: 500; color: var(--ink); }

.table .status-success { color: var(--ok); }
.table .status-error   { color: var(--err); }
.table .status-warning { color: var(--warn); }

/* ============================================
   Badge / Role
   ============================================ */

.badge-role {
    font-size: 10.5px;
    font-family: var(--mono);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 400;
    letter-spacing: .02em;
    display: inline-block;
    white-space: nowrap;
}

.badge-role.mgr-1   { background: var(--err-bg);  color: var(--err);  border: 1px solid var(--err-line); }
.badge-role.mgr-2   { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); }
.badge-role.employee{ background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); }

/* ============================================
   Scope Bar
   ============================================ */

.manager-scope-display {
    padding: 10px 16px;
    background: var(--info-bg);
    border-bottom: 1px solid var(--info-line);
    display: flex;
    align-items: center;
}

.scope-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--info);
}

.scope-info strong { font-weight: 500; }

/* ============================================
   Alerts
   ============================================ */

.alerts-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-item {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-2);
    border-radius: var(--radius);
    transition: all var(--t);
}

.alert-item:hover { border-color: var(--line-2); border-left-color: inherit; }

.alert-item.critical { border-left-color: var(--err);  background: var(--err-bg); }
.alert-item.high     { border-left-color: var(--warn); background: var(--warn-bg); }
.alert-item.medium   { border-left-color: var(--info); background: var(--info-bg); }
.alert-item.low      { border-left-color: var(--ok);   background: var(--ok-bg); }

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.alert-type {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}

.alert-time {
    font-size: 11.5px;
    font-family: var(--mono);
    color: var(--muted);
}

.alert-details {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.6;
}

.alert-details strong { color: var(--ink-3); font-weight: 500; }

/* ============================================
   Placeholder
   ============================================ */

.placeholder {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
    font-size: 13px;
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,10,11,.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn .15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 760px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
}

.modal-header h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -.01em;
}

.modal-close {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t);
}

.modal-close:hover { background: var(--surface-3); color: var(--ink); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-loading {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 13px;
}

/* ============================================
   Chart
   ============================================ */

.chart-container {
    position: relative;
    height: 280px;
    margin-top: 16px;
}

.modal-chart-300 { height: 300px; }
.modal-chart-320 { height: 320px; }

/* ============================================
   Metric Control
   ============================================ */

.metric-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.metric-control label {
    font-size: 11.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.metric-select {
    padding: 5px 28px 5px 10px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 12.5px;
    font-family: var(--sans);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238c8c99' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    outline: none;
    cursor: pointer;
}

/* ============================================
   Quarter Select
   ============================================ */

.quarter-select-row {
    display: flex;
    gap: 8px;
}

/* ============================================
   Audit Trail
   ============================================ */

.audit-trail-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 440px;
    overflow-y: auto;
}

.audit-header-row {
    display: grid;
    grid-template-columns: 36px 100px 90px 80px 90px 80px 1fr;
    gap: 8px;
    padding: 8px 14px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}

.audit-event-row {
    display: grid;
    grid-template-columns: 36px 100px 90px 80px 90px 80px 1fr;
    gap: 8px;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: background var(--t);
}

.audit-event-row:hover { background: var(--surface-3); }

.audit-row-fail {
    border-left: 2px solid var(--err);
    background: var(--err-bg);
}

.audit-row-fail:hover { background: #fee2e2; }

.audit-status.ok   { color: var(--ok);  font-size: 12px; font-weight: 500; }
.audit-status.fail { color: var(--err); font-size: 12px; font-weight: 500; }

.audit-seq  { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }
.audit-time { font-size: 12.5px; font-family: var(--mono); color: var(--ink); }
.audit-dir  { font-size: 12.5px; color: var(--ink-3); }
.audit-gate { font-size: 12px; font-family: var(--mono); color: var(--info); }
.audit-site { font-size: 12px; color: var(--muted); }
.audit-reason { font-size: 12px; color: var(--muted); }

/* ============================================
   Org Stats
   ============================================ */

.stats-grid-mb { margin-bottom: 20px; }

/* ============================================
   Clickable Row
   ============================================ */

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--surface-2) !important; }

/* ============================================
   Error Inline
   ============================================ */

.error-inline {
    color: var(--err);
    font-size: 13px;
    padding: 16px;
    background: var(--err-bg);
    border-radius: var(--radius);
    border: 1px solid var(--err-line);
}

/* ============================================
   Connection Result
   ============================================ */

#connection-result {
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.7;
    margin-top: 12px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    display: none;
}

#connection-result.success { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok); }
#connection-result.error   { border-color: var(--err-line); background: var(--err-bg); color: var(--err); }

/* Token Info */
#token-info {
    font-size: 12.5px;
    font-family: var(--mono);
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    line-height: 1.8;
    margin-top: 12px;
    word-break: break-all;
}

/* ============================================
   Utilities
   ============================================ */

.hidden { display: none !important; }

.flex-1 { flex: 1; }
.mr-15  { margin-right: 12px; }
.form-group-full { flex-basis: 100%; }
.filter-section-wrap { flex-wrap: wrap; }
.form-row-spaced { margin-bottom: 20px; }

/* ============================================
   Settings Sections
   ============================================ */

.settings-section { margin-bottom: 28px; }

.settings-section h4 {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 24px 0;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 6px;
    }

    .main-content { margin-left: 0; }
    .content-container { padding: 16px; }
    .card { padding: 16px; }
    .card-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .tier-selector { grid-template-columns: 1fr; }
    .direction-buttons { grid-template-columns: 1fr; }

    .top-header {
        flex-direction: column;
        height: auto;
        padding: 14px 16px;
        gap: 10px;
    }
}