:root {
    --bg-dark: #070a10;
    --bg-elevated: #0f141d;
    --bg-card: rgba(17, 23, 34, 0.92);
    --bg-soft: #151c28;
    --border: #273142;
    --border-strong: #39465c;
    --text: #f5f7fb;
    --text-muted: #98a4b7;
    --accent: #7c9cff;
    --accent-strong: #9eb5ff;
    --accent-soft: rgba(124, 156, 255, 0.13);
    --green: #55d68b;
    --red: #ff6b72;
    --amber: #f1bd64;
    --purple: #b794f6;
    --shadow: 0 20px 55px rgba(0, 0, 0, 0.25);
}

html {
    color-scheme: dark;
}

body {
    padding: 0;
    background:
        radial-gradient(circle at 15% -5%, rgba(75, 104, 196, 0.17), transparent 32rem),
        radial-gradient(circle at 95% 5%, rgba(91, 65, 147, 0.12), transparent 28rem),
        var(--bg-dark);
    color: var(--text);
    font-family: Inter, "Noto Sans TC", "Segoe UI", sans-serif;
    letter-spacing: 0.01em;
}

button,
input,
select {
    font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
}

.container {
    width: min(100% - 40px, 1520px);
    max-width: 1520px;
    margin: 0 auto;
    padding: 28px 0 64px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border: 1px solid rgba(158, 181, 255, 0.35);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(124, 156, 255, 0.28), rgba(124, 156, 255, 0.06));
    color: var(--accent-strong);
    font-size: 1.3rem;
    font-weight: 800;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.app-header h1 {
    margin: 0;
    font-size: clamp(1.35rem, 3vw, 2rem);
    letter-spacing: -0.035em;
}

.header-actions,
.live-status {
    display: flex;
    align-items: center;
}

.header-actions {
    gap: 10px;
}

.live-status {
    gap: 8px;
    min-height: 40px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(15, 20, 29, 0.78);
    color: var(--text-muted);
    font-size: 0.78rem;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(85, 214, 139, 0.09);
}

.btn {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
    font-weight: 650;
    transition: 150ms ease;
}

.btn:hover {
    border-color: var(--border-strong);
    background: #1b2433;
    transform: translateY(-1px);
}

.btn-primary {
    border-color: transparent;
    background: var(--accent);
    color: #081024;
}

.btn-primary:hover {
    border-color: transparent;
    background: var(--accent-strong);
}

.btn-compact {
    min-height: 34px;
    padding: 0 11px;
    font-size: 0.78rem;
}

.control-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
    gap: 14px;
    margin-bottom: 16px;
}

.control-card,
.account-panel,
.panel,
.container > section {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

.control-card {
    padding: 18px;
}

.control-card-head,
.panel-heading,
.section-header,
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.control-card h2,
.panel-heading h2,
.section-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 0.98rem;
}

.control-card p,
.panel-heading p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 150px auto;
    gap: 9px;
    margin-top: 14px;
}

.input,
.select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0b1018;
    color: var(--text);
    padding: 0 12px;
    transition: 150ms ease;
}

.input:hover,
.select:hover,
.input:focus,
.select:focus {
    border-color: var(--border-strong);
    background: #0d131d;
}

.range-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 15px;
}

.range-group {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #0b1018;
}

.range-btn {
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.range-btn:hover {
    border-color: transparent;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
}

.range-btn.active {
    border-color: transparent;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
}

.form-message {
    min-height: 18px;
    margin-top: 8px;
    color: var(--green);
    font-size: 0.78rem;
}

.account-panel {
    padding: 13px 14px 14px;
    margin-bottom: 16px;
}

.account-panel-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 9px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.account-selector {
    display: flex;
    gap: 7px;
    margin: 0;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.account-btn {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 650;
}

.account-btn:hover {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
}

.account-btn.active {
    border-color: rgba(124, 156, 255, 0.24);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.dashboard-section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin: 28px 2px 12px;
}

.dashboard-section-title h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.05rem;
}

.dashboard-section-title p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.selected-account {
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
    gap: 14px;
    margin-bottom: 14px;
}

.overview-stack {
    display: grid;
    gap: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.stat-card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(150deg, rgba(24, 32, 46, 0.94), rgba(14, 19, 28, 0.94));
    padding: 16px;
    backdrop-filter: none;
}

.stat-card .label {
    margin: 0 0 9px;
    color: var(--text-muted);
    font-size: 0.74rem;
}

.stat-card .value {
    overflow: hidden;
    font-size: clamp(1.2rem, 2.3vw, 1.75rem);
    letter-spacing: -0.03em;
    text-overflow: ellipsis;
}

.panel {
    min-width: 0;
    padding: 18px;
}

.panel-heading {
    margin-bottom: 14px;
}

.chart-container {
    height: 330px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.container > section {
    overflow: hidden;
    margin-bottom: 14px;
}

.section-header {
    width: 100%;
    min-height: 62px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    padding: 0 18px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.025);
}

.section-header:hover h2 {
    color: var(--text);
}

.section-kicker {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 400;
}

.toggle-icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    transform: rotate(0);
}

.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.section-content {
    padding: 0;
}

.table-container {
    margin: 0;
    overflow-x: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
}

table {
    min-width: 720px;
}

th,
td {
    padding: 13px 18px;
    border-bottom: 1px solid rgba(39, 49, 66, 0.75);
    font-size: 0.82rem;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #111722;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: rgba(124, 156, 255, 0.045);
}

.post-cell {
    display: flex;
    min-width: 260px;
    align-items: center;
    gap: 10px;
}

.post-type {
    display: grid;
    width: 31px;
    height: 31px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-soft);
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
}

.post-copy {
    min-width: 0;
}

.shortcode-link,
.post-title {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-weight: 650;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shortcode-link:hover {
    color: var(--accent-strong);
    text-decoration: none;
}

.post-meta {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.metric-cell {
    color: #dce3ef;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.badge {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 750;
}

.badge::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.badge-active {
    border-color: rgba(85, 214, 139, 0.2);
    background: rgba(85, 214, 139, 0.09);
    color: var(--green);
}

.badge-archived {
    border-color: rgba(152, 164, 183, 0.17);
    background: rgba(152, 164, 183, 0.08);
    color: var(--text-muted);
}

.badge-deleted {
    border-color: rgba(255, 107, 114, 0.22);
    background: rgba(255, 107, 114, 0.1);
    color: var(--red);
}

.row-deleted {
    background: rgba(255, 107, 114, 0.025);
}

.row-deleted .post-title {
    color: #b7beca;
    text-decoration: line-through;
}

.table-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 16, 24, 0.5);
}

.table-filters {
    display: grid;
    grid-template-columns: minmax(220px, 360px) 140px;
    gap: 8px;
}

.table-toolbar .input,
.table-toolbar .select {
    min-height: 36px;
    font-size: 0.78rem;
}

.result-count,
.data-status {
    color: var(--text-muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

.empty-state {
    padding: 32px 18px !important;
    color: var(--text-muted);
    text-align: center;
}

.modal-overlay {
    padding: 18px;
    background: rgba(2, 4, 8, 0.8);
    backdrop-filter: blur(10px);
}

.modal {
    border-color: var(--border-strong);
    background: #0e141e;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}

.modal-close {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

@media (max-width: 1050px) {
    .control-grid,
    .overview-grid {
        grid-template-columns: 1fr;
    }

    .overview-stack {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .container {
        width: min(100% - 24px, 1520px);
        padding-top: 18px;
    }

    .app-header {
        align-items: flex-start;
    }

    .live-status {
        display: none;
    }

    .btn-label {
        display: none;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .range-row,
    .table-toolbar,
    .dashboard-section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .range-group {
        width: 100%;
    }

    .range-btn {
        flex: 1;
    }

    .table-filters {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 285px;
    }

    .modal-overlay {
        padding: 8px;
    }
}

@media (max-width: 430px) {
    .brand-mark {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .stat-card {
        padding: 13px;
    }
}
