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

:root {
    --bg:        #0a0a0a;
    --surface:   #111111;
    --surface2:  #1a1a1a;
    --border:    #2a2a2a;
    --border2:   #333333;
    --text:      #e4e4e7;
    --muted:     #71717a;
    --accent:    #6366f1;
    --accent-h:  #4f46e5;
    --green:     #22c55e;
    --green-bg:  rgba(34,197,94,.12);
    --red:       #ef4444;
    --red-bg:    rgba(239,68,68,.12);
    --yellow:    #f59e0b;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: -.01em;
}
.topbar-brand .logo {
    width: 28px; height: 28px;
    background: var(--accent);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 800; color: #fff;
}
.topbar-right {
    display: flex; align-items: center; gap: 1rem;
}
.clock {
    font-size: .95rem;
    color: #fff;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    display: flex; align-items: center; gap: .35rem;
}
.clock svg { opacity: .6; }

/* ── Main layout ── */
.main { flex: 1; padding: 2rem; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ── Page header ── */
.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; }
.page-header p  { font-size: .85rem; color: var(--muted); margin-top: .25rem; }

/* ── Stats grid ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    display: flex; flex-direction: column; gap: .4rem;
    transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }
.stat-value.muted { color: var(--text); }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: .35rem; }
.stat-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.stat-dot.red   { background: var(--red);   box-shadow: 0 0 8px var(--red); }

/* ── Alert ── */
.alert {
    background: var(--green-bg);
    border: 1px solid rgba(34,197,94,.3);
    color: var(--green);
    padding: .75rem 1.1rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    display: flex; align-items: center; gap: .5rem;
}

/* ── Table card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .75rem;
}
.card-title { font-size: .875rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-title svg { color: var(--muted); }

table { border-collapse: collapse; width: 100%; table-layout: fixed; }
thead th {
    padding: .75rem 1.25rem;
    text-align: left;
    font-size: .72rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: .9rem 1.25rem;
    font-size: .875rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow: hidden;
}
tbody td:last-child { overflow: visible; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: var(--surface2); }

/* ── Table column helpers ── */
.td-synced { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: normal; line-height: 1.4; }
.td-count  { color: var(--muted); font-variant-numeric: tabular-nums; }
.td-latest { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }
.td-latest-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-latest--empty { color: var(--muted); font-size: .8rem; }

code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: .78rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 5px;
    color: var(--accent);
    letter-spacing: -.01em;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px;
    font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-fresh   { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,.25); }
.badge-fresh .badge-dot { background: var(--green); box-shadow: 0 0 5px var(--green); }
.badge-expired { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(239,68,68,.25); }
.badge-expired .badge-dot { background: var(--red); }
.badge-none    { background: rgba(113,113,122,.1); color: var(--muted); border: 1px solid var(--border); }
.badge-none .badge-dot { background: var(--muted); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    border: none; border-radius: 8px; cursor: pointer;
    font-weight: 600; font-size: .85rem;
    transition: all .2s; white-space: nowrap;
    text-decoration: none;
}
.btn-primary {
    background: var(--accent); color: #fff;
    padding: .5rem 1.1rem;
}
.btn-primary:hover { background: var(--accent-h); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.btn-primary:disabled { background: #3730a3; opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
    background: transparent; color: var(--muted);
    border: 1px solid var(--border);
    padding: .35rem .65rem; font-size: .78rem;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.08); }

.btn-icon {
    background: var(--surface2); color: var(--muted);
    border: 1px solid var(--border);
    width: 30px; height: 30px; border-radius: 7px;
    padding: 0; justify-content: center; font-size: 1rem;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.08); }

/* ── Actions cell ── */
.actions { display: flex; align-items: center; gap: .4rem; white-space: nowrap; overflow: visible; }

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; display: inline-block; }

/* ── Footer ── */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.footer-inner {
    max-width: 1100px; margin: 0 auto;
    padding: 1.25rem 2rem;
    font-size: .78rem; color: var(--muted);
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.footer-visitor {
    display: flex; align-items: center; gap: .6rem;
    font-size: .75rem; color: var(--muted);
    white-space: nowrap;
}
.footer-visitor svg { opacity: .6; flex-shrink: 0; }
.footer-visitor-item { display: flex; align-items: center; gap: .3rem; }
.footer-visitor-label { opacity: .6; }
.footer-visitor-count {
    font-weight: 600; color: #fff;
    font-variant-numeric: tabular-nums;
}
.footer-visitor-ip {
    font-weight: 600; color: var(--fg);
    font-family: ui-monospace, monospace; letter-spacing: .02em;
}
.footer-visitor-sep { opacity: .35; }

/* ── Accordion ── */
.accordion-row td {
    background: var(--bg) !important;
}
.accordion-panel {
    border-top: 1px solid var(--accent);
    overflow: hidden;
}
.acc-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1.25rem;
    background: rgba(99,102,241,.06);
    border-bottom: 1px solid var(--border);
}
.acc-title {
    display: flex; align-items: center; gap: .5rem;
    font-size: .82rem; font-weight: 600; color: var(--accent);
}
.acc-actions { display: flex; align-items: center; gap: .5rem; }
.acc-body {
    padding: 1rem 1.25rem;
    max-height: 340px;
    overflow-y: auto;
    overflow-x: hidden;
}
.acc-loading {
    display: flex; align-items: center; gap: .5rem;
    color: var(--muted); font-size: .85rem; padding: .5rem 0;
}
.acc-item {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}
.acc-item:last-child { border-bottom: none; }
.acc-num {
    font-size: .7rem; color: var(--muted); min-width: 20px;
    padding-top: 2px; text-align: right; font-variant-numeric: tabular-nums;
}
.acc-item-content { flex: 1; min-width: 0; overflow: hidden; }
.acc-item-title,
.acc-item-title:visited {
    font-size: .85rem; color: var(--text); font-weight: 500;
    text-decoration: none; display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-item-title:hover,
.acc-item-title:focus { color: var(--accent); text-decoration: underline; }
.acc-item-date { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.acc-empty { color: var(--muted); font-size: .85rem; text-align: center; padding: 1.5rem 0; }
.acc-copy.copied { border-color: var(--green); color: var(--green); }

/* Active RSS button state */
.btn-rss-preview.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(99,102,241,.1);
}

/* ── Responsive Table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
    .topbar-inner { padding: 0 1.25rem; }
    .main { padding: 1.25rem 1rem; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .topbar-inner { padding: 0 1rem; }
    .main { padding: 1rem .75rem; }
    .stats { grid-template-columns: repeat(2, 1fr); gap: .65rem; }
    .stat-card { padding: .85rem 1rem; }
    .stat-value { font-size: 1.3rem; }
    table { min-width: 800px; }
    .btn-rss-preview span { display: none; }
    .card-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .page-header h1 { font-size: 1.2rem; }
    .page-header p  { font-size: .78rem; }
}
