:root {
    color-scheme: dark;
    --bg: #080d15;
    --surface: #111a26;
    --surface-2: #172233;
    --line: #2b3c52;
    --text: #f4f7fb;
    --muted: #9cb0c9;
    --blue: #358ae6;
    --blue-dark: #1769bd;
    --green: #7de35d;
    --red: #ff6b72;
    --orange: #f3b85b;
    --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 10% 0%, #11294a 0, transparent 32rem), var(--bg);
}

a { color: inherit; }
.site-header {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px clamp(18px, 4vw, 64px);
    border-bottom: 1px solid var(--line);
    background: rgba(8, 13, 21, .94);
}
.brand { text-decoration: none; font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; }
.brand span { color: var(--blue); }
.brand b { font-weight: 650; color: #c7d6e9; }
.nav-actions { display: flex; align-items: center; gap: 16px; color: var(--muted); }
.nav-actions a { color: #9dcbff; text-decoration: none; font-weight: 700; }
.nav-actions form { margin: 0; }
.user-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-button { border: 0; background: none; color: #ff9aa0; font: inherit; font-weight: 700; cursor: pointer; padding: 0; }

.page-shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 60px; }
.site-footer { padding: 22px; text-align: center; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
h1, h2 { margin-top: 0; letter-spacing: -.025em; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 5vw, 3.1rem); }
h2 { margin-bottom: 14px; font-size: 1.2rem; }
p { line-height: 1.55; }
.eyebrow { margin: 0 0 9px; color: #82bcff; font-size: .78rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }

.auth-shell { min-height: 64vh; display: grid; place-items: center; }
.auth-card, .panel, .tool-card, .empty-state {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(23, 34, 51, .96), rgba(13, 21, 32, .96));
    box-shadow: 0 20px 60px rgba(0, 0, 0, .24);
}
.auth-card { width: min(460px, 100%); padding: clamp(26px, 5vw, 44px); }
.wide-card { width: min(760px, 100%); }
.stack-form, .form-grid { display: grid; gap: 16px; margin-top: 25px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.compact { margin-top: 15px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 8px; color: #d9e4f2; font-size: .9rem; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid #3a4d66;
    border-radius: 10px;
    background: #0b121c;
    color: var(--text);
    padding: 12px 13px;
    font: inherit;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53, 138, 230, .18); }
input[readonly] { color: var(--muted); background: #111925; }
textarea { resize: vertical; }
.button, .small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: .16s ease;
}
.button { min-height: 44px; padding: 10px 18px; }
.button.primary { color: white; background: var(--blue); }
.button.primary:hover { background: var(--blue-dark); transform: translateY(-1px); }
.button.secondary { border-color: #48627f; background: #172437; color: #dceaff; }
.button.full { width: 100%; }
.button.disabled { cursor: default; color: #7f91a6; background: #222d3b; }
.small-button { padding: 7px 10px; color: #dceaff; border-color: #405670; background: #172437; font-size: .82rem; }
.small-button.danger { color: #ffb2b6; border-color: #74434a; }
.danger-button { color: white; background: #b93d47; }
.danger-button:hover { background: #982f38; }
.delete-panel { margin-bottom: 20px; border-color: #74434a; }
.delete-confirmation { display: grid; gap: 16px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; }
.checkbox-label input { width: auto; }

.flash { width: min(1240px, calc(100% - 32px)); margin: 18px auto 0; padding: 13px 16px; border-radius: 10px; border: 1px solid; }
.auth-card .flash { width: 100%; margin: 18px 0; }
.flash-success { color: #c9ffbb; border-color: #477e43; background: #142a1b; }
.flash-error { color: #ffc4c7; border-color: #7c4149; background: #2a151b; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); gap: 20px; }
.tool-card { min-height: 280px; padding: 26px; display: flex; flex-direction: column; }
.tool-card h2 { margin: 18px 0 8px; font-size: 1.45rem; }
.tool-card > p { color: #b3c3d6; flex: 1; }
.category-badge { align-self: start; padding: 7px 10px; border-radius: 999px; color: #a9d5ff; background: rgba(53, 138, 230, .13); border: 1px solid rgba(53, 138, 230, .35); font-size: .76rem; font-weight: 800; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; border-top: 1px solid var(--line); }
.access-time { color: var(--muted); font-size: .84rem; }
.empty-state { padding: 48px; text-align: center; }
.empty-state p { color: var(--muted); }

.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.panel { padding: 24px; }
.span-full { grid-column: 1 / -1; }
.access-form { grid-template-columns: 1.2fr 1.2fr 1fr 1fr auto; align-items: end; margin-top: 10px; }
.table-panel { margin-top: 20px; padding: 0; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.panel-heading span { color: var(--muted); font-size: .85rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid #223249; vertical-align: middle; }
th { color: #93b5d8; background: #101925; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; }
td { color: #d8e3f0; font-size: .9rem; }
tbody tr:last-child td { border-bottom: 0; }
.url-cell { max-width: 310px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.status-active { color: #baffaa; background: #17321e; }
.status-blocked, .status-cancelled, .status-expired { color: #ffabb0; background: #35191e; }
.status-pending { color: #ffd995; background: #352a16; }
.inline-form { margin: 0; }
.row-actions { display: flex; align-items: center; gap: 8px; }

@media (max-width: 900px) {
    .admin-grid { grid-template-columns: 1fr; }
    .access-form { grid-template-columns: repeat(2, 1fr); }
    .access-form .button { grid-column: span 2; }
    .span-full { grid-column: auto; }
}

@media (max-width: 660px) {
    .site-header { align-items: flex-start; flex-direction: column; }
    .nav-actions { width: 100%; flex-wrap: wrap; }
    .user-name { display: none; }
    .page-shell { width: min(100% - 22px, 1240px); padding-top: 28px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .form-grid, .access-form { grid-template-columns: 1fr; }
    .span-2, .access-form .button { grid-column: auto; }
    .card-footer { align-items: stretch; flex-direction: column; }
    .tool-card, .panel, .empty-state { padding: 20px; }
    .table-panel { padding: 0; }
}

