:root {
    color-scheme: light;
    --ink: #17221d;
    --muted: #647168;
    --line: #dce5df;
    --paper: #ffffff;
    --canvas: #f4f7f5;
    --brand: #176b45;
    --brand-soft: #e6f3ec;
    --danger: #a53c32;
    --warning: #8a5a13;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
}

button, input, select { font: inherit; }
.hidden { display: none !important; }

.topbar {
    min-height: 68px;
    padding: 12px clamp(18px, 4vw, 54px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: white;
    background: var(--brand);
    font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.secondary-link { color: var(--brand); text-decoration: none; }
.account-name { color: var(--muted); }

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto 60px;
}

.hero, .panel-heading, .auth-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
}

.hero { margin-bottom: 24px; }
.hero h1 { margin: 7px 0; font-size: clamp(28px, 4vw, 42px); }
.hero p, .panel-heading p, .field-help { color: var(--muted); }

.eyebrow {
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
}

.panel, .auth-panel {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--paper);
    box-shadow: 0 10px 32px rgba(30, 50, 39, .05);
}

.tab-list {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    padding: 5px;
    width: fit-content;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
}

.tab-button {
    color: var(--muted);
    background: transparent;
}

.tab-button.active {
    color: white;
    background: var(--brand);
}

.tab-panel > .panel + .panel,
.section-panel,
#userSubscriptionOverview {
    margin-top: 20px;
}

.effective-panel {
    border-color: #c9ded1;
    background: linear-gradient(135deg, #ffffff 0%, #f5fbf7 100%);
}

.panel-heading { align-items: flex-start; margin-bottom: 20px; }
.panel-heading h2 { margin: 4px 0 0; }
.panel-heading p { margin: 3px 0 0; }

.subscription-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.subscription-card, .policy-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdfb;
}

.subscription-card h3, .policy-card h3 { margin: 0 0 8px; }
.subscription-status { font-weight: 700; color: var(--brand); }
.subscription-status.off { color: var(--muted); }
.subscription-status.warning { color: var(--warning); }
.source-summary { min-height: 44px; color: var(--muted); font-size: 14px; }
.updated-at { color: var(--muted); font-size: 13px; }

.card-actions, .form-actions, .policy-actions, .inline-field {
    display: flex;
    gap: 10px;
    align-items: center;
}

.card-actions { margin-top: 14px; }
.card-actions input { width: 112px; }
.admin-section { margin-top: 24px; }
.admin-layout { display: grid; grid-template-columns: 1fr 1.15fr; gap: 20px; }

.user-search-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.user-search-field {
    width: min(360px, 100%);
    margin-bottom: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field > span:first-child { font-weight: 650; }

input, select {
    min-width: 0;
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #c9d5cd;
    border-radius: 9px;
    color: var(--ink);
    background: white;
}

input:focus, select:focus {
    outline: 2px solid rgba(23, 107, 69, .18);
    border-color: var(--brand);
}

button, .primary-link {
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}

button:disabled { opacity: .55; cursor: not-allowed; }
.primary-button, .primary-link { color: white; background: var(--brand); }
.secondary-button, .small-button { color: var(--brand); background: white; border-color: #b9cec1; }
.small-button { flex: 0 0 auto; }

.toggle-field { display: flex; gap: 9px; align-items: center; margin: 5px 0 18px; }
.toggle-field input { width: auto; min-height: auto; }
.target-preview { color: var(--muted); min-height: 22px; }
.field-help { font-size: 13px; margin-bottom: 0; }

.policy-list { display: grid; gap: 12px; }
.policy-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.chip, .count-chip {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 13px;
}

.policy-actions { margin-top: 13px; }
.empty-list { color: var(--muted); }
.error-banner, .toast { margin-bottom: 18px; padding: 12px 15px; border-radius: 10px; }
.error-banner { color: var(--danger); background: #fff0ee; }
.toast { color: var(--brand); background: var(--brand-soft); }

@media (max-width: 900px) {
    .subscription-grid, .admin-layout { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
    .topbar, .hero, .panel-heading, .auth-panel { align-items: flex-start; flex-direction: column; }
    .page-shell { width: min(100% - 20px, 1180px); margin-top: 20px; }
    .panel { padding: 18px; }
    .form-grid { grid-template-columns: 1fr; }
    .topbar-actions { justify-content: flex-start; }
    .tab-list { width: 100%; }
    .tab-button { flex: 1; }
    .user-search-row { align-items: stretch; flex-direction: column; }
}
