/* VECTRO Admin Panel — Dark Theme */
:root {
    --bg: #0f0f13;
    --surface: #1a1a22;
    --surface2: #22222e;
    --border: #2e2e3e;
    --accent: #6c63ff;
    --accent2: #a78bfa;
    --green: #34d399;
    --red: #f87171;
    --yellow: #fbbf24;
    --text: #e2e8f0;
    --text2: #94a3b8;
    --text3: #64748b;
    --radius: 10px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---- Light Theme ---- */
[data-theme="light"] {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface2: #f5f5f8;
    --border: #e0e0e8;
    --accent: #6c63ff;
    --accent2: #7c6fcd;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #d97706;
    --text: #1a1a2e;
    --text2: #4a4a6a;
    --text3: #8888a0;
}
[data-theme="light"] .modal-overlay { background: rgba(0,0,0,0.3); }
[data-theme="light"] #chart-tooltip { background: rgba(255,255,255,0.95); }
[data-theme="light"] .skeleton {
    background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
    background-size: 200% 100%;
}
[data-theme="light"] .type-badge.static  { background: #dbeafe; color: #2563eb; }
[data-theme="light"] .type-badge.php     { background: #ede9fe; color: #7c3aed; }
[data-theme="light"] .type-badge.nodejs  { background: #dcfce7; color: #16a34a; }
[data-theme="light"] .col-settings-dropdown { box-shadow: 0 8px 24px rgba(0,0,0,.12); }

/* Theme toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 15px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    margin-left: 8px;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text);
}
.logo span { color: var(--accent2); }

.server-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text2);
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text3);
    transition: background 0.3s;
}
.dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.offline { background: var(--red); }

.metric {
    margin-left: 16px;
    font-size: 12px;
    color: var(--text3);
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: border-color 0.15s;
}

.card h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.card.collapsed h2 {
    margin-bottom: 0;
}

/* Drag handle */
.card-drag {
    color: var(--text3);
    font-size: 16px;
    cursor: grab;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
    letter-spacing: 2px;
    flex-shrink: 0;
}
.card-drag:hover {
    color: var(--text2);
    background: var(--surface2);
}
.card-drag:active { cursor: grabbing; }

/* Collapse toggle */
.card-toggle {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s, transform 0.2s;
    line-height: 1;
    font-family: var(--font);
    flex-shrink: 0;
}
.card-toggle:hover {
    color: var(--text2);
    background: var(--surface2);
}
.card.collapsed .card-toggle {
    transform: rotate(-90deg);
}

/* Drag-and-drop states */
.card.dragging {
    opacity: 0.45;
}
.card.drop-before {
    border-top: 2px solid var(--accent);
}
.card.drop-after {
    border-bottom: 2px solid var(--accent);
}

/* Card body */
.card-body {
    /* intentionally no default styles */
}
.card.collapsed .card-body {
    display: none;
}

.badge {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text2);
}

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

.status-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-tile {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
}

.stat-label {
    font-size: 10px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.stat-value.ok    { color: var(--green); }
.stat-value.error { color: var(--red); }
.stat-value.warn  { color: var(--yellow); }
.stat-value small {
    font-size: 11px;
    font-weight: 400;
    color: var(--text3);
    margin-left: 2px;
}

.tile-sub, .stat-sub {
    font-size: 10px;
    color: var(--text3);
}
.sub-danger { color: var(--red); }
.sub-warn   { color: var(--yellow); }

/* PM2 group */
.pm2-group {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.pm2-group-label {
    font-size: 10px;
    color: var(--text3);
    text-transform: uppercase;
    font-weight: 600;
    white-space: nowrap;
}
.pm2-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.pm2-chips .stat-tile {
    border: none;
    background: var(--bg);
    padding: 4px 10px;
}

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

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text3);
    border-bottom: 1px solid var(--border);
}

thead th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
thead th.sortable:hover { color: var(--text2); }

thead th.sortable::after {
    content: '⇅';
    margin-left: 5px;
    opacity: 0.25;
    font-size: 10px;
}
thead th.sort-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--accent2);
}
thead th.sort-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--accent2);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td {
    padding: 10px 12px;
    color: var(--text2);
    vertical-align: middle;
}

.site-link {
    color: var(--accent2);
    text-decoration: none;
    font-weight: 500;
}
.site-link:hover { text-decoration: underline; }

/* Subdomain cell — domain & white-label buttons */
.subdomain-cell { display: flex; flex-direction: column; gap: 4px; }

.link-domain-btn,
.white-label-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    background: transparent;
    color: var(--text3);
    font-size: 11px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    white-space: nowrap;
    width: fit-content;
}
.link-domain-btn:hover { border-color: var(--accent); color: var(--accent); }
.white-label-btn:hover { border-color: var(--accent); color: var(--accent); }

.domain-linked {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(52,211,153,.1);
    border: 1px solid rgba(52,211,153,.25);
    border-radius: 14px;
    width: fit-content;
}
.wl-active {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}
.domain-linked-url {
    color: #34d399;
    text-decoration: none;
    font-weight: 500;
}
.domain-linked-url:hover { color: #6ee7b7; text-decoration: underline; }
.wl-url {
    color: var(--text3);
    text-decoration: none;
}
.wl-url:hover { color: var(--accent2); }

.unlink-domain-btn,
.unwhite-label-btn {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 12px;
    padding: 0 3px;
    line-height: 1;
    opacity: .5;
    transition: opacity .15s, color .15s;
}
.unlink-domain-btn:hover,
.unwhite-label-btn:hover { opacity: 1; color: var(--red); }

/* Client cell with edit button */
.client-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}
.edit-btn {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    line-height: 1;
    flex-shrink: 0;
}
tr:hover .edit-btn { opacity: 1; }
.edit-btn:hover {
    background: var(--surface2);
    color: var(--accent2);
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.type-badge.static  { background: #1e3a5f; color: #60a5fa; }
.type-badge.php     { background: #3b1f6e; color: #c084fc; }
.type-badge.nodejs  { background: #14532d; color: #4ade80; }
.type-badge.unknown { background: var(--surface2); color: var(--text3); }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}
.status-badge .dot { width: 6px; height: 6px; }
.status-badge.active .dot   { background: var(--green); }
.status-badge.inactive .dot { background: var(--text3); }
.status-badge.error .dot    { background: var(--red); }

.disk-cell { color: var(--text3); font-size: 12px; font-family: monospace; }
.date-cell { color: var(--text3); font-size: 12px; white-space: nowrap; }
.git-cell  { color: var(--text3); font-size: 11px; font-family: monospace; }

td.loading { text-align: center; color: var(--text3); padding: 32px; }

/* ---- Sites toolbar ---- */

.sites-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

/* ---- Search ---- */

.search-bar {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 14px;
    height: 14px;
    color: var(--text3);
    pointer-events: none;
    flex-shrink: 0;
}

.search-bar input {
    width: 100%;
    max-width: 380px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 14px 9px 36px;
    font-size: 13px;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text3); }

.search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 13px;
    line-height: 1;
    padding: 4px 5px;
    cursor: pointer;
    border-radius: 4px;
    display: none;
    transition: color 0.15s, background 0.15s;
}
.search-clear:hover { color: var(--text); background: var(--surface3); }
.search-bar.has-value .search-clear { display: flex; align-items: center; }
.search-bar.has-value input { padding-right: 30px; }

/* ---- Column settings ---- */

.col-settings-wrap {
    position: relative;
    flex-shrink: 0;
}

.col-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text3);
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.col-settings-btn:hover,
.col-settings-btn.active { border-color: var(--accent); color: var(--accent); }

.col-settings-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 0;
    min-width: 180px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.col-settings-dropdown.open { display: block; }

.col-settings-dropdown label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text2);
    cursor: pointer;
    transition: background .1s;
    user-select: none;
}
.col-settings-dropdown label:hover { background: var(--surface2); }

.col-settings-dropdown input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* ---- Chart tooltip ---- */

#chart-tooltip {
    position: fixed;
    background: rgba(8, 8, 14, 0.93);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 7px 12px;
    pointer-events: none;
    display: none;
    z-index: 2000;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#chart-tooltip .tt-time {
    color: var(--text3);
    font-size: 11px;
    margin-bottom: 3px;
}
#chart-tooltip .tt-val {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

/* ---- Pagination ---- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.pag-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text2);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.pag-btn:hover:not(:disabled) {
    background: var(--border);
    color: var(--text);
}
.pag-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pag-info {
    font-size: 13px;
    color: var(--text2);
    min-width: 130px;
    text-align: center;
}
.pag-total {
    color: var(--text3);
    font-size: 12px;
}

/* ---- Demo button ---- */

.demo-cell { white-space: nowrap; }

.demo-btn {
    background: var(--surface3);
    border: 1px solid var(--border);
    color: var(--text3);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
}
.demo-btn:hover { border-color: var(--accent); color: var(--accent); }
.demo-btn.demo-on {
    background: linear-gradient(90deg, #6c63ff22, #a78bfa22);
    border-color: var(--accent);
    color: var(--accent);
}
.demo-btn:disabled { opacity: 0.5; cursor: default; }
.demo-days {
    display: block;
    font-size: 10px;
    color: var(--accent);
    opacity: 0.7;
    margin-top: 2px;
    text-align: center;
}

/* ---- Toggle site button ---- */

.toggle-cell { width: 36px; text-align: center; }

.toggle-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 28px; height: 28px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
    display: inline-flex; align-items: center; justify-content: center;
}
.toggle-btn.toggle-on { color: #34d399; border-color: #34d39944; }
.toggle-btn.toggle-on:hover { background: #34d39915; border-color: #34d399; }
.toggle-btn.toggle-off { color: #f87171; border-color: #f8717144; }
.toggle-btn.toggle-off:hover { background: #f8717115; border-color: #f87171; }
.toggle-btn:disabled { opacity: 0.4; cursor: default; }

tr.row-disabled td { opacity: 0.45; }
tr.row-disabled .toggle-cell td,
tr.row-disabled .toggle-cell { opacity: 1; }
tr.row-disabled .toggle-btn { opacity: 1; }

/* ---- Skeleton ---- */

.skeleton {
    height: 80px;
    background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Login page ---- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text);
    margin-bottom: 6px;
}
.login-logo span { color: var(--accent2); }

.login-subtitle {
    font-size: 13px;
    color: var(--text3);
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-field input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 14px;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}
.login-field input:focus { border-color: var(--accent); }
.login-field input::placeholder { color: var(--text3); }

.login-error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--red);
    text-align: center;
}

.login-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 4px;
}
.login-btn:hover  { opacity: 0.88; }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.login-link {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    text-align: center;
    padding: 4px;
    transition: color 0.2s;
}
.login-link:hover { color: var(--accent2); }

/* ---- Header buttons ---- */

.header-btn {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    margin-left: 8px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}
.header-btn:hover { background: var(--surface2); color: var(--text); }

/* ---- Modal ---- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(2px);
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 28px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text3);
    margin-bottom: 20px;
    line-height: 1.6;
}

.token-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    font-family: monospace;
    font-size: 13px;
    color: var(--accent2);
    word-break: break-all;
    margin-bottom: 20px;
    letter-spacing: 0.03em;
}

.modal-actions { display: flex; gap: 10px; }
.modal-actions .login-btn { flex: 1; }

.modal-close-btn {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text2);
    cursor: pointer;
    transition: background 0.2s;
}
.modal-close-btn:hover { background: var(--border); }

.modal-hint { margin-top: 10px; font-size: 13px; color: var(--green); }

/* Native <dialog> modals (link-domain, white-label) */
dialog {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 16px 48px rgba(0,0,0,.5);
    max-width: 420px;
    width: 90vw;
}
dialog::backdrop {
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(2px);
}
.modal-inner {
    padding: 24px;
}
.modal-inner h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}
.modal-inner .modal-sub {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 14px;
    line-height: 1.5;
}
.modal-inner .modal-hint {
    font-size: 12px;
    color: var(--yellow);
    margin-bottom: 10px;
    line-height: 1.5;
}
.modal-inner .modal-info {
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 14px;
}
.modal-inner input[type="text"] {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    margin-bottom: 14px;
    transition: border-color .15s;
}
.modal-inner input[type="text"]:focus {
    border-color: var(--accent);
}
.modal-inner .modal-actions {
    display: flex;
    gap: 8px;
}
.btn-primary {
    flex: 1;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
    flex: 1;
    background: var(--surface2);
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background .15s;
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
    flex: 1;
    background: rgba(248,113,113,.15);
    color: var(--red);
    border: 1px solid rgba(248,113,113,.3);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: opacity .15s;
}
.btn-danger:hover { opacity: .85; }

/* Dialog status messages */
.ldm-pending, .wlm-pending { color: var(--yellow); font-size: 12px; margin-top: 10px; }
.ldm-ok, .wlm-ok           { color: var(--green); font-size: 12px; margin-top: 10px; }
.ldm-error, .wlm-error     { color: var(--red); font-size: 12px; margin-top: 10px; }

/* Rename modal */
#modal-rename .modal-desc {
    text-align: left;
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 14px;
    font-family: monospace;
}
#modal-rename .login-field {
    text-align: left;
}
.rename-error {
    margin-top: 10px;
    font-size: 13px;
    color: var(--red);
    text-align: center;
}

/* ---- OpenRouter stat tile ---- */

.or-tile-label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.or-cfg-btn {
    opacity: 1 !important;
    font-size: 11px;
    padding: 1px 4px;
    margin-left: auto;
}

.or-tile-sub {
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
}

/* Integrations modal */
.integrations-list {
    text-align: left;
    margin-bottom: 4px;
}

.integration-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.integration-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.integration-logo { font-size: 20px; flex-shrink: 0; }

.integration-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.integration-desc {
    font-size: 12px;
    color: var(--text3);
    margin-top: 1px;
}

.integration-status {
    margin-left: auto;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 20px;
    flex-shrink: 0;
}
.integration-status.status-ok    { background: rgba(52,211,153,.15); color: var(--green); }
.integration-status.status-error { background: rgba(248,113,113,.15); color: var(--red); }
.integration-status.status-none  { background: var(--surface); color: var(--text3); }

/* ---- Billing ---- */

.billing-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px dashed var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text3);
    font-size: 11px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    white-space: nowrap;
}
.billing-btn:hover { border-color: var(--accent); color: var(--accent); }

.billing-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity .15s;
    white-space: nowrap;
}
.billing-badge:hover { opacity: .8; }

.billing-badge.ok      { background: rgba(52,211,153,.12); color: #34d399; border-color: rgba(52,211,153,.25); }
.billing-badge.soon    { background: rgba(251,191,36,.12); color: #fbbf24; border-color: rgba(251,191,36,.25); }
.billing-badge.expired { background: rgba(248,113,113,.12); color: #f87171; border-color: rgba(248,113,113,.25); }
.billing-badge.unset   { background: var(--surface2); color: var(--text3); border-color: var(--border); }

/* Billing modal */
.billing-modal-inner {
    text-align: left;
    max-width: 440px;
    width: 100%;
}
.billing-modal-inner .modal-title { text-align: center; }

.billing-field {
    margin-bottom: 14px;
}
.billing-field label {
    display: block;
    font-size: 11px;
    color: var(--text3);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.billing-field input {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    box-sizing: border-box;
}
.billing-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.billing-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

.billing-payments-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.billing-payments-title span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
}

.billing-add-btn {
    padding: 4px 12px;
    border: 1px solid var(--accent);
    border-radius: 16px;
    background: transparent;
    color: var(--accent);
    font-size: 11px;
    cursor: pointer;
    transition: background .15s;
}
.billing-add-btn:hover { background: rgba(108,99,255,.1); }

.billing-add-form {
    display: none;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    gap: 8px;
}
.billing-add-form.open { display: grid; grid-template-columns: 1fr 1fr; }
.billing-add-form .billing-field { margin-bottom: 0; }
.billing-add-form .billing-note-field { grid-column: 1 / -1; }
.billing-add-form .billing-add-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 4px; }

.billing-payment-list {
    max-height: 180px;
    overflow-y: auto;
}
.billing-payment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text2);
}
.billing-payment-item:last-child { border-bottom: none; }
.billing-payment-date { color: var(--text3); min-width: 72px; }
.billing-payment-amount { font-weight: 600; color: var(--text); }
.billing-payment-note { flex: 1; color: var(--text3); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.billing-payment-del {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
    opacity: .5;
    transition: opacity .15s, color .15s;
}
.billing-payment-del:hover { opacity: 1; color: var(--red); }

.billing-empty { color: var(--text3); font-size: 12px; text-align: center; padding: 12px; }

.billing-reset-link {
    display: block;
    text-align: center;
    margin-top: 10px;
    font-size: 11px;
    color: var(--text3);
    cursor: pointer;
    border: none;
    background: none;
    text-decoration: underline;
    text-decoration-style: dashed;
}
.billing-reset-link:hover { color: var(--red); }

/* Billing alert tile */
.billing-alert-tile {
    cursor: pointer;
    transition: border-color .15s;
}
.billing-alert-tile:hover { border-color: var(--yellow); }
.billing-alert-tile .stat-value { color: var(--yellow); }

/* ---- Charts ---- */

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-wrap {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
}

.chart-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

.chart-title {
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

canvas {
    display: block;
    width: 100%;
    height: 90px;
    border-radius: 4px;
}

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

@media (max-width: 768px) {
    main { padding: 12px; }
    .card { padding: 14px 16px; }
    .status-grid { gap: 6px; }
    .metric { display: none; }
    .charts-grid { grid-template-columns: 1fr; }
    .search-bar input { max-width: 100%; }
}
