:root {
    --bg: #090d16;
    --panel: rgba(16, 22, 36, .86);
    --panel-solid: #111827;
    --panel-soft: #171f31;
    --line: rgba(148, 163, 184, .16);
    --line-strong: rgba(148, 163, 184, .28);
    --text: #f7f9fc;
    --soft: #c5cedd;
    --muted: #7f8ba3;
    --blue: #4f7cff;
    --blue-bright: #6b93ff;
    --orange: #ff6633;
    --green: #2dd4a7;
    --yellow: #f6be4a;
    --red: #ff5f67;
    --shadow: 0 28px 80px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% -10%, rgba(79, 124, 255, .2), transparent 31rem),
        radial-gradient(circle at 92% 0%, rgba(255, 102, 51, .1), transparent 26rem),
        linear-gradient(135deg, #080c14, #0c111d 48%, #0a0f1a);
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
input, select, textarea {
    width: 100%;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: rgba(6, 10, 18, .65);
    outline: none;
    padding: 11px 13px;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79, 124, 255, .14); background: rgba(7, 12, 22, .92); }
textarea { resize: vertical; }
select { min-width: 180px; }
option { background: #111827; }
label { display: grid; gap: 7px; color: var(--soft); font-size: .8rem; font-weight: 700; }

.app-shell { width: min(100% - 32px, 1600px); margin: 0 auto; padding-bottom: 54px; }
.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.brand-lockup { display: flex; align-items: center; gap: 11px; width: max-content; }
.brand-lockup img { width: 38px; height: 38px; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(64, 122, 236, .28)); }
.brand-lockup div { display: grid; gap: 1px; }
.brand-lockup span { color: var(--orange); font-size: .61rem; font-weight: 800; letter-spacing: .14em; }
.brand-lockup strong { font-size: 1rem; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.today-chip { display: grid; justify-items: end; gap: 2px; padding-right: 4px; }
.today-chip span { color: var(--muted); font-size: .72rem; text-transform: capitalize; }
.today-chip strong { color: var(--soft); font-size: .78rem; }
.icon-button, .close-button { display: inline-grid; place-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--soft); cursor: pointer; }
.icon-button { width: 38px; height: 38px; border-radius: 50%; }
.icon-button:hover, .close-button:hover { border-color: var(--line-strong); color: #fff; background: rgba(255,255,255,.08); }

main { display: grid; gap: 22px; padding-top: 35px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.hero-row h1 { margin: 7px 0 7px; font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1; letter-spacing: -.065em; }
.hero-row p { margin: 0; color: var(--muted); font-size: .92rem; }
.hero-actions { display: flex; gap: 9px; }
.eyebrow { color: var(--blue-bright); text-transform: uppercase; letter-spacing: .14em; font-size: .65rem; font-weight: 800; }

.button { border: 1px solid transparent; border-radius: 11px; min-height: 40px; padding: 9px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: #fff; font-size: .78rem; font-weight: 800; cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease; white-space: nowrap; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { background: linear-gradient(135deg, #426fea, var(--blue)); border-color: #668dff; box-shadow: 0 10px 26px rgba(79,124,255,.18); }
.button.primary:hover { background: linear-gradient(135deg, #4d79f2, #5b84ff); }
.button.secondary { background: rgba(255,255,255,.075); border-color: var(--line-strong); }
.button.ghost { background: transparent; border-color: var(--line); color: var(--soft); }
.button.small { min-height: 34px; padding: 7px 10px; font-size: .72rem; }
.button.wide { width: 100%; min-height: 46px; }
.button-dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.13); }

.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat-card { position: relative; overflow: hidden; min-height: 132px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, rgba(23,31,49,.82), rgba(13,19,31,.84)); box-shadow: 0 14px 38px rgba(0,0,0,.13); transition: border-color .18s ease, transform .18s ease; }
a.stat-card:hover { transform: translateY(-2px); border-color: rgba(107,147,255,.36); }
.stat-card::after { content: ''; position: absolute; width: 72px; height: 72px; top: -34px; right: -26px; border-radius: 50%; background: rgba(79,124,255,.08); }
.stat-card.accent::after { background: rgba(79,124,255,.22); }
.stat-card.danger::after { background: rgba(255,95,103,.2); }
.stat-card span { color: var(--soft); font-size: .72rem; font-weight: 700; }
.stat-card strong { font-size: 2rem; letter-spacing: -.06em; line-height: 1; }
.stat-card small { color: var(--muted); font-size: .65rem; }

.content-card { border: 1px solid var(--line); border-radius: 20px; background: rgba(13, 19, 31, .78); box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(16px); }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 21px 22px 15px; }
.card-heading h2 { margin: 5px 0 0; font-size: 1.15rem; letter-spacing: -.035em; }
.result-count { padding: 7px 10px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.04); font-size: .7rem; }
.tabs { display: flex; gap: 3px; padding: 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { position: relative; padding: 12px 12px 13px; color: var(--muted); font-size: .73rem; font-weight: 700; white-space: nowrap; }
.tabs a.active { color: #fff; }
.tabs a.active::after { content: ''; position: absolute; height: 2px; left: 10px; right: 10px; bottom: -1px; background: var(--blue); border-radius: 2px; }
.filters { display: flex; align-items: center; gap: 9px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filters select { width: auto; min-width: 190px; }
.search-field { position: relative; display: block; flex: 1; min-width: 220px; }
.search-field span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.1rem; }
.search-field input { padding-left: 35px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1160px; }
th { padding: 12px 15px; color: #6f7c94; font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; text-align: left; background: rgba(6,10,18,.28); }
td { padding: 14px 15px; border-top: 1px solid rgba(148,163,184,.105); vertical-align: middle; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(255,255,255,.023); }
.domain-cell, .date-cell { display: grid; gap: 4px; }
.domain-cell strong { max-width: 310px; overflow: hidden; text-overflow: ellipsis; color: #e9eef9; font-size: .77rem; }
.domain-cell small, .date-cell small, .cadence { color: var(--muted); font-size: .63rem; }
.date-cell strong { color: var(--soft); font-size: .72rem; }
.date-cell.due strong { color: #fff; }
.package-pill { display: block; width: max-content; max-width: 140px; padding: 5px 8px; color: #bcc8dc; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.035); font-size: .65rem; font-weight: 700; }
.cadence { display: block; margin-top: 5px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid; border-radius: 999px; font-size: .61rem; font-weight: 800; }
.status-pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-pill.overdue { color: #ff8b92; background: rgba(255,95,103,.1); border-color: rgba(255,95,103,.25); }
.status-pill.today { color: #f9ce71; background: rgba(246,190,74,.09); border-color: rgba(246,190,74,.24); }
.status-pill.upcoming { color: #69dec0; background: rgba(45,212,167,.08); border-color: rgba(45,212,167,.22); }
.network-summary { display: inline-flex; align-items: center; gap: 9px; padding: 0; color: var(--soft); background: none; border: 0; cursor: pointer; font-size: .66rem; font-weight: 700; }
.network-stack { display: flex; padding-left: 6px; }
.network-stack i { width: 26px; height: 26px; margin-left: -6px; display: inline-grid; place-items: center; border: 2px solid #111827; border-radius: 50%; color: #fff; background: var(--network-color); font-style: normal; font-size: .5rem; font-weight: 800; box-shadow: 0 3px 9px rgba(0,0,0,.24); }
.network-stack i.empty { color: var(--muted); background: #182033; border-color: #111827; font-size: .9rem; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.empty-state { display: grid; place-items: center; gap: 6px; min-height: 230px; color: var(--muted); text-align: center; }
.empty-state span { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(45,212,167,.25); border-radius: 50%; color: var(--green); background: rgba(45,212,167,.08); }
.empty-state strong { color: var(--soft); font-size: .85rem; }
.empty-state p { margin: 0; font-size: .72rem; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .69rem; }
.pagination a { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--soft); }
.pagination a.disabled { pointer-events: none; opacity: .35; }
.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; }

.alert { padding: 12px 14px; border: 1px solid; border-radius: 12px; font-size: .75rem; line-height: 1.45; }
.alert.error { color: #ffc0c4; background: rgba(255,95,103,.09); border-color: rgba(255,95,103,.24); }
.alert.success { color: #96ecd6; background: rgba(45,212,167,.08); border-color: rgba(45,212,167,.22); }

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 18px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(1,4,10,.78); backdrop-filter: blur(9px); animation: fadeIn .15s ease both; }
.modal-panel { position: relative; z-index: 1; width: min(100%, 740px); max-height: calc(100vh - 36px); overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 20px; background: #111827; box-shadow: 0 35px 110px rgba(0,0,0,.65); animation: modalIn .2s ease both; }
.wide-modal { width: min(100%, 980px); }
.compact-modal { width: min(100%, 520px); }
.modal-header { position: sticky; top: 0; z-index: 4; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 20px 22px; border-bottom: 1px solid var(--line); background: rgba(17,24,39,.96); backdrop-filter: blur(12px); }
.modal-header h2 { margin: 5px 0 4px; font-size: 1.3rem; letter-spacing: -.04em; }
.modal-header p { margin: 0; color: var(--muted); font-size: .72rem; }
.close-button { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; font-size: 1.25rem; }
.modal-toolbar { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 0; flex-wrap: wrap; }
.modal-panel form { padding: 16px 22px 0; }
.compact-modal form { padding-top: 20px; display: grid; gap: 16px; }
.modal-footer { position: sticky; bottom: 0; z-index: 4; display: flex; justify-content: flex-end; gap: 8px; margin: 18px -22px 0; padding: 14px 22px; border-top: 1px solid var(--line); background: rgba(17,24,39,.96); backdrop-filter: blur(12px); }
.shared-card { display: grid; grid-template-columns: minmax(180px,.7fr) 1.3fr; gap: 20px; align-items: center; padding: 15px; border: 1px solid rgba(79,124,255,.22); border-radius: 14px; background: rgba(79,124,255,.06); }
.shared-card strong { font-size: .79rem; }
.shared-card p { margin: 4px 0 0; color: var(--muted); font-size: .67rem; line-height: 1.45; }
.shared-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input-action { display: grid; grid-template-columns: 1fr auto; }
.input-action input { border-radius: 9px 0 0 9px; }
.input-action button { padding: 0 11px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 9px 9px 0; color: var(--soft); background: rgba(255,255,255,.04); cursor: pointer; font-size: .65rem; }
.network-list { display: grid; gap: 8px; padding-top: 15px; }
.network-item { border: 1px solid var(--line); border-radius: 14px; background: rgba(7,11,20,.36); overflow: hidden; }
.network-item-header { display: flex; align-items: center; gap: 11px; padding: 11px 13px; }
.network-check { position: relative; width: 19px; height: 19px; flex: 0 0 auto; }
.network-check input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.network-check i { width: 19px; height: 19px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 5px; color: transparent; background: rgba(255,255,255,.03); font-style: normal; font-size: .7rem; }
.network-check input:checked + i { color: #fff; border-color: var(--blue); background: var(--blue); }
.network-logo { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--network-color); font-size: .55rem; font-weight: 800; }
.network-name { flex: 1; font-size: .75rem; font-weight: 800; }
.network-state { color: var(--muted); font-size: .62rem; }
.network-details { display: none; grid-template-columns: 1.25fr .8fr .8fr; gap: 10px; padding: 2px 13px 13px 73px; }
.network-item.enabled .network-details { display: grid; }
.network-details .full { grid-column: 1 / -1; }
.inline-check { display: flex; align-items: center; gap: 7px; font-size: .68rem; cursor: pointer; }
.inline-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }
.notes-field { margin-top: 15px; }
.empty-network-state { min-height: 145px; display: grid; place-content: center; gap: 5px; padding: 20px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-align: center; }
.empty-network-state strong { color: var(--soft); font-size: .76rem; }
.empty-network-state span { font-size: .68rem; }
.history-block { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.section-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.section-title strong { font-size: .78rem; }
.section-title span { color: var(--muted); font-size: .64rem; }
.history-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(148,163,184,.09); font-size: .67rem; }
.history-row span { color: var(--soft); }
.history-row p { margin: 0; color: var(--muted); }
.history-row small { color: var(--muted); }
.loading-state { min-height: 150px; display: grid; place-items: center; color: var(--muted); font-size: .72rem; }

.credentials-list { display: grid; gap: 10px; padding: 18px 22px; }
#credentialsForm .credentials-list { padding-inline: 0; }
.credentials-editor { grid-template-columns: 1fr; align-items: stretch; }
.credential-summary { padding: 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(7,11,20,.3); font-size: .7rem; line-height: 1.5; }
.credential-card { display: grid; gap: 9px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(7,11,20,.42); }
.credential-card > strong { color: var(--soft); font-size: .75rem; }
.credential-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.copy-field { display: grid; grid-template-columns: 1fr auto; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.03); }
.copy-field div { min-width: 0; padding: 8px 9px; }
.copy-field span { display: block; color: var(--muted); font-size: .56rem; text-transform: uppercase; }
.copy-field code { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--soft); font-family: inherit; font-size: .68rem; margin-top: 2px; }
.copy-field button { width: 34px; border: 0; border-left: 1px solid var(--line); color: var(--soft); background: transparent; cursor: pointer; }
.copy-field button:hover { background: rgba(255,255,255,.06); }

.network-picker-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 18px 22px; }
.network-picker-option { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: rgba(7,11,20,.34); cursor: pointer; text-align: left; }
.network-picker-option:hover { border-color: rgba(79,124,255,.55); background: rgba(79,124,255,.08); }
.network-picker-option strong { flex: 1; font-size: .72rem; }
.network-picker-option small { color: var(--blue-2); font-size: .61rem; font-weight: 700; }
#networkPickerModal .modal-footer { margin: 0; }

.toast-region { position: fixed; z-index: 200; right: 18px; bottom: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: 360px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--soft); background: #182033; box-shadow: 0 18px 46px rgba(0,0,0,.4); font-size: .72rem; animation: toastIn .2s ease both; }
.toast.success { border-color: rgba(45,212,167,.28); }
.toast.error { border-color: rgba(255,95,103,.32); }

.auth-page { display: grid; place-items: center; padding: 22px; }
.auth-shell { width: min(100%, 440px); }
.auth-card { padding: 28px; border: 1px solid var(--line-strong); border-radius: 22px; background: rgba(15,22,36,.88); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.auth-copy { margin: 34px 0 22px; }
.auth-copy h1 { margin: 7px 0 8px; font-size: 2rem; letter-spacing: -.055em; }
.auth-copy p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.auth-form { display: grid; gap: 14px; margin-top: 18px; }
.security-note { margin: 17px 0 0; color: #66738a; font-size: .61rem; line-height: 1.5; text-align: center; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-card { min-height: 115px; }
}
@media (max-width: 760px) {
    .app-shell { width: min(100% - 20px, 1600px); }
    .topbar { min-height: 70px; }
    .today-chip { display: none; }
    main { padding-top: 24px; gap: 16px; }
    .hero-row { align-items: flex-start; flex-direction: column; }
    .hero-row .button { width: 100%; }
    .hero-actions { width: 100%; flex-direction: column; }
    .hero-row h1 { font-size: 2.1rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { min-height: 106px; padding: 14px; }
    .stat-card strong { font-size: 1.65rem; }
    .filters { align-items: stretch; flex-direction: column; }
    .filters select { width: 100%; }
    .card-heading { padding-inline: 15px; }
    .tabs { padding-inline: 8px; }
    .modal { padding: 0; align-items: flex-end; }
    .modal-panel, .wide-modal, .compact-modal { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; }
    .modal-header, .modal-toolbar { padding-inline: 16px; }
    .modal-panel form { padding-inline: 16px; }
    .modal-footer { margin-inline: -16px; padding-inline: 16px; }
    .shared-card { grid-template-columns: 1fr; }
    .shared-fields { grid-template-columns: 1fr; }
    .network-details { grid-template-columns: 1fr; padding-left: 13px; }
    .credential-pair { grid-template-columns: 1fr; }
    .network-picker-grid { grid-template-columns: 1fr; padding-inline: 16px; }
}
@media (max-width: 440px) {
    .brand-lockup span { display: none; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-grid .stat-card:last-child { grid-column: 1 / -1; }
    .auth-card { padding: 22px; }
}
