/* ==========================================================================
   STEALIT — Design System (Vercel-style)
   Monochrome surfaces, 1px borders, sharp radii, no gradients, no glow.
   ========================================================================== */

:root {
    --background: #313338;
    --surface: #2b2d31;
    --surface-2: #1e1f22;
    --surface-3: #404249;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.12);
    --border-hover: #5865f2;
    --text: #dbdee1;
    --text-bright: #f2f3f5;
    --text-secondary: #b5bac1;
    --text-tertiary: #949ba4;
    --text-muted: #80848e;
    --blue: #5865f2;
    --blue-dim: rgba(88, 101, 242, 0.15);
    --red: #f23f43;
    --red-dim: rgba(242, 63, 67, 0.12);
    --green: #23a55a;
    --green-dim: rgba(35, 165, 90, 0.12);
    --amber: #f0b232;
    --amber-dim: rgba(240, 178, 50, 0.12);
    --font-sans: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--background);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

::selection {
    background: var(--blue);
    color: #ffffff;
}

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* ---------- Scrollbars ---------- */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-mark svg {
    width: 22px;
    height: 22px;
    color: var(--text);
}

.brand-name {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    white-space: nowrap;
}

.brand-divider {
    color: var(--border-strong);
    font-size: 13px;
    user-select: none;
}

.topbar-title {
    font-size: 13px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-side {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- Page shell ---------- */

.page {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.page-narrow {
    max-width: 560px;
}

.page-header {
    margin-bottom: 28px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.page-desc {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 640px;
}

.page-desc svg {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-right: 4px;
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card + .card {
    margin-top: 16px;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.card-desc {
    padding: 14px 20px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.card-desc svg {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-right: 4px;
}

.card-body {
    padding: 20px;
}

/* ---------- Grid ---------- */

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.15s ease;
}

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

.stat-value {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    user-select: none;
}

.btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn:disabled,
.btn.loading {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--text);
    color: #000000;
    border-color: var(--text);
}

.btn-primary:hover {
    background: #cccccc;
    border-color: #cccccc;
}

.btn-primary:active {
    background: #999999;
    border-color: #999999;
}

.btn-secondary {
    background: var(--background);
    color: var(--text);
    border-color: var(--border-strong);
}

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

.btn-secondary:active {
    background: var(--surface-3);
}

.btn-danger {
    background: var(--red);
    color: #ffffff;
    border-color: var(--red);
}

.btn-danger:hover {
    background: #d43b41;
    border-color: #d43b41;
}

.btn-danger:active {
    background: #c22f35;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-sm svg {
    width: 13px;
    height: 13px;
}

.btn-lg {
    padding: 12px 22px;
    font-size: 15px;
}

.btn .spin {
    animation: spin 0.8s linear infinite;
}

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

/* ---------- Forms ---------- */

.field {
    margin-bottom: 18px;
}

.label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.label svg {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.input,
.select,
.textarea,
.file {
    width: 100%;
    padding: 9px 12px;
    background: var(--background);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.input:hover,
.select:hover,
.textarea:hover,
.file:hover {
    border-color: var(--border-hover);
}

.input:focus,
.select:focus,
.textarea:focus,
.file:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-dim);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-muted);
}

.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 34px;
    cursor: pointer;
}

.textarea {
    resize: vertical;
    min-height: 110px;
}

.file {
    padding: 8px 10px;
    cursor: pointer;
}

.file::file-selector-button {
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 10px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    margin-right: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.file::file-selector-button:hover {
    background: #262626;
}

.input-mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

.input-error {
    border-color: var(--red) !important;
    box-shadow: 0 0 0 3px var(--red-dim) !important;
}

.hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ---------- Tables ---------- */

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

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

.table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table th svg {
    width: 12px;
    height: 12px;
    vertical-align: -1px;
    margin-right: 5px;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color 0.1s ease;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

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

.table td .btn {
    pointer-events: auto;
}

.cell-mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text);
    user-select: text;
}

/* ---------- Badges & dots ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge svg {
    width: 11px;
    height: 11px;
}

.badge-success {
    background: var(--green-dim);
    color: #4ade80;
    border-color: rgba(41, 163, 131, 0.35);
}

.badge-error {
    background: var(--red-dim);
    color: #f87171;
    border-color: rgba(229, 72, 77, 0.35);
}

.badge-warning {
    background: var(--amber-dim);
    color: var(--amber);
    border-color: rgba(245, 166, 35, 0.35);
}

.badge-blue {
    background: var(--blue-dim);
    color: #66aaff;
    border-color: rgba(0, 112, 243, 0.35);
}

.badge-neutral {
    background: var(--surface-3);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-success {
    background: var(--green);
}

.dot-error {
    background: var(--red);
}

.dot-warning {
    background: var(--amber);
}

.dot-blue {
    background: var(--blue);
}

.dot-pulse {
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ---------- Notifications ---------- */

.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    max-width: 380px;
    padding: 12px 16px 12px 14px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.5;
    display: none;
    align-items: flex-start;
    gap: 10px;
    animation: toastIn 0.25s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.notification.show,
.notification[style*="block"] {
    display: flex;
}

.notification.success {
    border-left: 3px solid var(--green);
}

.notification.error {
    border-left: 3px solid var(--red);
}

.notification.warning {
    border-left: 3px solid var(--amber);
}

.notification.info {
    border-left: 3px solid var(--blue);
}

.notification.fade-out {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.notification svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification.success svg { color: var(--green); }
.notification.error svg { color: var(--red); }
.notification.warning svg { color: var(--amber); }
.notification.info svg { color: var(--blue); }

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

/* ---------- Modals ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.modal-box.modal-lg {
    max-width: 680px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-head h3 svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background-color 0.15s ease;
}

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

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-body p {
    margin: 0 0 12px;
    color: var(--text-secondary);
    font-size: 14px;
    word-break: break-all;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- Action grid (control panels, menus) ---------- */

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.action-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 500;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.action-tile:hover {
    border-color: var(--border-hover);
    background: var(--surface-2);
    transform: translateY(-1px);
}

.action-tile:active {
    transform: translateY(0);
}

.action-tile svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.action-tile:hover svg {
    color: var(--text);
}

.action-tile.tile-danger svg {
    color: var(--red);
}

.action-tile.tile-warning svg {
    color: var(--amber);
}

.action-tile.tile-blue svg {
    color: var(--blue);
}

/* ---------- Key-value rows ---------- */

.kv {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.kv-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-label {
    font-size: 13px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.kv-label svg {
    width: 14px;
    height: 14px;
}

.kv-value {
    font-size: 13.5px;
    color: var(--text);
    word-break: break-all;
    text-align: right;
}

.kv-value.mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

/* ---------- Utilities ---------- */

.mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.muted {
    color: var(--text-tertiary);
}

.secondary-text {
    color: var(--text-secondary);
}

.divider {
    height: 1px;
    background: var(--border);
    border: none;
    margin: 20px 0;
}

.link {
    color: var(--blue);
    text-decoration: none;
    transition: color 0.15s ease;
}

.link:hover {
    color: #3291ff;
    text-decoration: underline;
}

.section-gap {
    margin-top: 24px;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

.fade-in {
    animation: fadeIn 0.35s ease;
}

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

.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.21, 1.02, 0.73, 1);
}

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

/* ---------- Footer ---------- */

.footer {
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    text-align: center;
}

.footer p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12.5px;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .page {
        padding: 24px 16px 48px;
    }

    .topbar-inner {
        padding: 12px 16px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 20px;
    }

    .notification {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }

    .action-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .kv-value {
        text-align: left;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .brand-name {
        letter-spacing: 0.14em;
    }

    .topbar-title {
        display: none;
    }

    .action-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Victims chart (dashboard)
   ========================================================================== */
.chart-wrap {
    width: 100%;
}

.victim-chart {
    width: 100%;
    height: auto;
    display: block;
}

.ch-grid {
    stroke: var(--border);
    stroke-width: 1;
}

.ch-num {
    font: 10px var(--font-mono);
    fill: var(--text-tertiary);
    text-anchor: end;
}

.ch-lab {
    font: 10px var(--font-mono);
    fill: var(--text-tertiary);
    text-anchor: middle;
}

.ch-bar {
    fill: var(--blue);
    transition: opacity 0.12s ease;
}

.ch-bar:hover {
    opacity: 0.75;
}

.ch-zero {
    fill: var(--surface-3);
}

.chart-note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}