:root {
    --bg: #121212;
    --bg-soft: #171717;
    --panel: rgba(27, 27, 27, 0.92);
    --panel-strong: rgba(34, 34, 34, 0.98);
    --line: rgba(255, 255, 255, 0.08);
    --text: #f0f0f0;
    --muted: #a5a5a5;
    --accent: #4798F7;
    --accent-2: #d0d0d0;
    --danger: #ff6b7a;
    --success: #76e0a0;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    --radius: 24px;
    --radius-sm: 16px;
    --font: "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.05), transparent 24%),
        linear-gradient(180deg, #101010 0%, #181818 55%, #111111 100%);
}

.app-shell { min-height: 100vh; padding: 14px; }
.view.hidden { display: none; }
.glass-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow);
}

.login-card {
    width: min(460px, 100%);
    margin: 10vh auto 0;
    padding: 28px;
    border-radius: 32px;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 20px;
}

.login-brand {
    width: 100%;
    justify-content: center;
}

.brand-logo {
    display: block;
    width: min(100%, 320px);
    height: auto;
}

.eyebrow {
    color: var(--accent-2);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 10px;
    margin-bottom: 6px;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 18px; }
.lead { color: var(--muted); line-height: 1.45; margin: 8px 0 18px; font-size: 14px; }
.stack { display: grid; gap: 12px; }
label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
input, select, textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
}

textarea { min-height: 72px; resize: vertical; }

.primary-button, .ghost-button, .danger-button {
    border: 0;
    border-radius: 10px;
    padding: 8px 12px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, opacity 0.16s ease;
    font-size: 13px;
}

.primary-button {
    background: linear-gradient(135deg, var(--accent), #5aa7ff);
    color: white;
}

.ghost-button {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid var(--line);
}

.danger-button {
    background: rgba(255, 107, 122, 0.14);
    color: #ffd5db;
    border: 1px solid rgba(255, 107, 122, 0.18);
}

.primary-button:hover, .ghost-button:hover, .danger-button:hover { transform: translateY(-1px); }

.error-text { color: #ff9fb0; min-height: 20px; font-size: 14px; }

.topbar {
    border-radius: 18px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.topbar-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    min-width: max-content;
}

.topbar-actions, .toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.search-shell {
    position: relative;
    display: flex;
    align-items: center;
    min-width: min(440px, 56vw);
}

.search-shell input {
    padding-left: 32px;
}

.search-icon {
    position: absolute;
    left: 10px;
    width: 14px;
    height: 14px;
    color: var(--muted);
    pointer-events: none;
}

.search-icon svg,
.icon-button svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.layout {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.summary-card {
    padding: 12px;
    border-radius: 14px;
}

.summary-card h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 10px;
}

.summary-card strong { display: block; font-size: clamp(18px, 2vw, 24px); }

.section-card {
    border-radius: var(--radius);
    padding: 14px;
}

.section-card-tight { padding: 12px; }

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.table-wrap {
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

.table-wrap-tall { max-height: calc(100vh - 230px); }
.table-wrap-medium { max-height: calc(100vh - 280px); }

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 0;
    font-size: 12px;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) { min-width: 120px; }

th, td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
}

td.editable-cell[data-type]:not([data-type="domains"]):not([data-type="urls"]) {
    white-space: nowrap;
    word-break: normal;
}

th {
    position: sticky;
    top: 0;
    background: var(--panel-strong);
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    z-index: 1;
}

td.editable-cell:hover { background: rgba(71, 152, 247, 0.08); }
td.actions { white-space: nowrap; width: 1%; }
td .cell-note { color: var(--muted); font-size: 11px; margin-top: 2px; }
.domain-stack,
.url-stack {
    display: grid;
    gap: 2px;
    line-height: 1.25;
    white-space: normal;
}

.status-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-mark.is-active {
    background: rgba(118, 224, 160, 0.14);
    color: #9ef0bc;
}

.status-mark.is-cancelled {
    background: rgba(255, 107, 122, 0.14);
    color: #ffb3bd;
}

.year-group-row td {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #f1f1f1;
    font-weight: 700;
    padding: 8px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.customer-row.year-tone-0 td,
.year-group-row.year-tone-0 td { background: rgba(255, 255, 255, 0.08); }

.customer-row.year-tone-1 td,
.year-group-row.year-tone-1 td { background: rgba(71, 152, 247, 0.20); }

.customer-row.year-tone-2 td,
.year-group-row.year-tone-2 td { background: rgba(118, 224, 160, 0.16); }

.customer-row.year-tone-3 td,
.year-group-row.year-tone-3 td { background: rgba(255, 107, 122, 0.16); }

.customer-row.year-tone-4 td,
.year-group-row.year-tone-4 td { background: rgba(255, 196, 87, 0.16); }

.customer-row td {
    transition: background 0.12s ease;
}

.row-flash td {
    box-shadow: inset 0 0 0 999px rgba(71, 152, 247, 0.12);
}
.cell-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(71, 152, 247, 0.14);
    color: #cfe5ff;
    font-size: 11px;
}

.sheet-nav {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-radius: 16px;
    flex-wrap: wrap;
}

.sheet-tab {
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.sheet-tab.active {
    background: rgba(71, 152, 247, 0.18);
    color: var(--text);
    border-color: rgba(71, 152, 247, 0.28);
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
}

.icon-button span {
    display: inline-flex;
    width: 15px;
    height: 15px;
}

.icon-delete {
    width: 28px;
    min-width: 28px;
    height: 28px;
}

.icon-delete span {
    width: 13px;
    height: 13px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sheet-panel.hidden { display: none; }
.sheet-panel.active {
    display: grid;
    gap: 10px;
}

.toast {
    position: fixed;
    right: 14px;
    bottom: 14px;
    background: rgba(10, 15, 24, 0.92);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    font-size: 13px;
}

.toast.hidden { display: none; }

.inline-editor {
    min-width: 160px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 30;
}

.modal-overlay.hidden { display: none; }

.modal-card {
    width: min(760px, 100%);
    max-height: calc(100vh - 40px);
    border-radius: 18px;
    padding: 14px;
    overflow: auto;
}

.modal-head,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.modal-head {
    margin-bottom: 12px;
}

.modal-form {
    display: grid;
    gap: 12px;
}

.modal-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.modal-field {
    display: grid;
    gap: 5px;
}

.modal-field.full {
    grid-column: 1 / -1;
}

.modal-field label {
    color: var(--muted);
    font-size: 12px;
}

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

@media (max-width: 980px) {
    .app-shell { padding: 10px; }
    .topbar, .section-head, .toolbar, .topbar-actions {
        display: grid;
    }
    .toolbar input, .toolbar button, .topbar-actions button, .topbar-actions select { width: 100%; }
    .table-wrap-tall, .table-wrap-medium { max-height: none; }
    .search-shell { min-width: 0; }
    .modal-fields { grid-template-columns: 1fr; }
}
