:root {
  color-scheme: light;
  --ink: #172234;
  --muted: #667085;
  --line: #dbe1e8;
  --soft: #f4f7fa;
  --blue: #075baa;
  --blue-dark: #064780;
  --red: #e71920;
  --green: #087a55;
  --amber: #9a5b00;
  --white: #fff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: #eef2f6; color: var(--ink); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.admin-shell { min-height: 100vh; }
.login-view {
  width: min(440px, calc(100% - 32px));
  margin: 9vh auto 40px;
  padding: 32px;
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 4px solid var(--red);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(23, 34, 52, .12);
}
.login-brand, .admin-brand { display: flex; align-items: center; gap: 13px; }
.login-brand img { width: 76px; height: 76px; object-fit: contain; }
.login-brand span, .admin-brand span, .page-heading p, .detail-dialog span { color: var(--blue); font-size: 12px; font-weight: 800; }
.login-brand h1 { margin: 3px 0 0; font-size: 25px; }
.login-copy { margin: 22px 0; color: var(--muted); line-height: 1.6; }
.login-view form { display: grid; gap: 13px; }
.login-view label, .search-field { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 700; }
.login-view input, .search-field input {
  width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: #fff;
  border: 1px solid #b8c2cf; border-radius: 6px; outline: none;
}
.login-view input:focus, .search-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7, 91, 170, .12); }
.primary-action, .secondary-action, .logout-action, .text-action {
  min-height: 42px; padding: 9px 15px; border-radius: 6px; font-weight: 750; border: 1px solid transparent;
}
.primary-action { background: var(--blue); color: #fff; }
.primary-action:hover { background: var(--blue-dark); }
.secondary-action { background: #fff; color: var(--blue); border-color: #aebdca; }
.logout-action { background: #fff; color: #b42318; border-color: #e8b8b4; }
.text-action { background: transparent; color: var(--blue); }
.form-status { min-height: 22px; margin: 15px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.form-status.error { color: #b42318; }

.dashboard-view { min-height: 100vh; }
.admin-header {
  min-height: 72px; padding: 10px clamp(18px, 4vw, 52px); display: flex; align-items: center; justify-content: space-between;
  gap: 18px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.admin-brand { color: inherit; text-decoration: none; }
.admin-brand img { width: 48px; height: 48px; object-fit: contain; }
.admin-brand div { display: grid; gap: 2px; }
.admin-brand strong { font-size: 16px; }
.header-actions { display: flex; gap: 8px; }
.admin-tools { position:relative; flex-shrink:0; }
.admin-menu-toggle { display:none; }
.header-actions > a,.header-actions > button { white-space:nowrap; text-decoration:none; }
.header-actions [data-view].active { color:white; background:var(--blue); border-color:var(--blue); }
.header-actions span { display:inline-grid; place-items:center; min-width:20px; padding:2px 5px; border-radius:4px; background:var(--soft); color:var(--blue); font-size:11px; }
@media(max-width:1200px) {
  .admin-menu-toggle { display:inline-flex; align-items:center; gap:8px; min-height:42px; }
  .admin-menu-toggle::after { content:'\25BE'; font-size:12px; }
  .admin-menu-toggle[aria-expanded=true]::after { content:'\25B4'; }
  .header-actions { display:none; position:absolute; top:calc(100% + 10px); right:0; width:min(340px,calc(100vw - 28px)); box-sizing:border-box; padding:10px; background:white; border:1px solid var(--line); border-radius:6px; box-shadow:0 8px 24px #10203024; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .admin-tools.is-open .header-actions { display:grid; }
  .header-actions > button,.header-actions > a { min-width:0; min-height:44px; padding:10px 8px; white-space:normal; text-align:center; display:flex; align-items:center; justify-content:center; font-size:13px; }
}
.page-heading { padding: 34px clamp(18px, 4vw, 52px) 22px; background: #fff; border-bottom: 1px solid var(--line); }
.page-heading p { margin: 0 0 6px; }
.page-heading h1 { margin: 0 0 8px; font-size: clamp(25px, 3vw, 34px); letter-spacing: 0; }
.page-heading span { color: var(--muted); font-size: 13px; }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; padding: 22px clamp(18px, 4vw, 52px); }
.summary-grid article { min-height: 122px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 7px; display: grid; align-content: space-between; }
.summary-grid article:nth-child(1) { border-top: 3px solid var(--blue); }
.summary-grid article:nth-child(2) { border-top: 3px solid var(--red); }
.summary-grid article:nth-child(3) { border-top: 3px solid var(--green); }
.summary-grid article:nth-child(4) { border-top: 3px solid #f0a000; }
.summary-grid article:nth-child(5) { border-top: 3px solid #6f42c1; }
.summary-grid article:nth-child(6) { border-top: 3px solid #00a37a; }
.summary-grid span { color: var(--muted); font-size: 13px; font-weight: 700; }
.summary-grid strong { margin: 6px 0; font-size: 27px; --metric-font-size:27; }
.summary-grid article,.report-summary article { min-width:0; }
.summary-grid strong,.report-summary strong { min-width:0; max-width:100%; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.summary-grid strong.metric-fit,.report-summary strong.metric-fit { display:block; width:100%; white-space:nowrap; overflow-wrap:normal; letter-spacing:0; }
.summary-grid small { color: var(--muted); }

.data-workspace { margin: 0 clamp(18px, 4vw, 52px) 48px; background: #fff; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.data-workspace { scroll-margin-top:90px; }
.data-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.data-tabs button { min-height: 54px; padding: 0 18px; white-space: nowrap; color: var(--muted); background: #fff; border: 0; border-bottom: 3px solid transparent; font-weight: 750; }
.data-tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.data-tabs span { display: inline-grid; min-width: 23px; height: 23px; margin-left: 6px; padding: 0 6px; place-items: center; background: var(--soft); border-radius: 12px; font-size: 11px; }
.table-tools { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 18px; border-bottom: 1px solid var(--line); }
.search-field { width: min(520px, 100%); }
.table-status { min-height: 0; padding: 0 18px; color: var(--muted); font-size: 13px; }
.table-status:not(:empty) { padding-top: 12px; }
.month-groups { display: grid; gap: 10px; padding: 14px 18px 18px; background: #f8fafc; }
.month-group { background: #fff; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.month-group summary { min-height: 58px; padding: 12px 15px; display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; list-style: none; }
.month-group summary::-webkit-details-marker { display: none; }
.month-group summary::after { content: "+"; width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; color: var(--blue); background: var(--soft); border-radius: 50%; font-size: 20px; font-weight: 700; }
.month-group[open] summary::after { content: "−"; }
.month-group summary strong { text-transform: capitalize; }
.month-group summary span { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 700; text-align: right; }
.month-group .table-scroll { border-top: 1px solid var(--line); }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 14px; color: #475467; background: var(--soft); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
td { padding: 14px; border-bottom: 1px solid #ebeff3; vertical-align: top; }
tbody tr:hover { background: #f8fafc; }
td strong, td span { display: block; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.test-data-badge { width: fit-content; margin-top: 6px; padding: 3px 6px; color: #7a4700; background: #fff0cc; border-radius: 4px; font-size: 10px; font-weight: 800; }
.missing-account-badge { width: fit-content; margin-top: 6px; padding: 3px 6px; color: #a3241b; background: #fde5e3; border-radius: 4px; font-size: 10px; font-weight: 800; }
.row-action { padding: 6px 10px; color: var(--blue); background: #fff; border: 1px solid #aebdca; border-radius: 5px; font-weight: 700; }
.status-pill { display: inline-flex; width: fit-content; padding: 4px 8px; border-radius: 4px; color: #344054; background: #e9eef3; font-size: 11px; font-weight: 800; }
.status-pill.success { color: #06613f; background: #dff6eb; }
.status-pill.warning { color: #7a4700; background: #fff0cc; }
.status-pill.danger { color: #a3241b; background: #fde5e3; }
.empty-state { padding: 50px 20px; text-align: center; }
.empty-state strong { font-size: 18px; }
.empty-state p { max-width: 480px; margin: 8px auto 0; color: var(--muted); line-height: 1.5; }

.period-report { padding: 22px; }
.analytics-panel { padding: 22px; background: #f8fafc; }
.analytics-heading span { color: var(--blue); font-size: 12px; font-weight: 800; }
.analytics-heading h2 { margin: 4px 0 6px; font-size: 23px; letter-spacing: 0; }
.analytics-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.analytics-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.analytics-kpis article, .analytics-chart-card, .analytics-lists article { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.analytics-kpis article { min-height: 94px; display: grid; align-content: space-between; }
.analytics-kpis span { color: var(--muted); font-size: 12px; font-weight: 750; }
.analytics-kpis strong { margin-top: 8px; font-size: 24px; }
.analytics-chart-card { margin-top: 10px; }
.analytics-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.analytics-card-heading h3 { margin: 0; font-size: 16px; }
.analytics-card-heading span { color: var(--muted); font-size: 11px; font-weight: 700; }
.analytics-bars { height: 190px; display: grid; grid-template-columns: repeat(30, minmax(4px, 1fr)); align-items: end; gap: 4px; margin-top: 18px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.analytics-bar-column { height: 100%; display: grid; grid-template-rows: 1fr 20px; align-items: end; gap: 5px; text-align: center; }
.analytics-bar-column i { width: 100%; min-height: 3px; align-self: end; border-radius: 3px 3px 0 0; background: var(--blue); }
.analytics-bar-column span { color: var(--muted); font-size: 9px; }
.analytics-lists { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 10px; margin-top: 10px; }
.analytics-list-item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 13px 0 9px; overflow: hidden; border-bottom: 1px solid #edf1f5; }
.analytics-list-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #344054; font-size: 12px; }
.analytics-list-item strong { font-size: 12px; }
.analytics-list-item i { position: absolute; bottom: 4px; left: 0; height: 3px; border-radius: 3px; background: var(--blue); opacity: .65; }
.analytics-empty { margin: 20px 0 0; color: var(--muted); font-size: 13px; }
.report-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.report-heading span { color: var(--blue); font-size: 12px; font-weight: 800; }
.report-heading h2 { margin: 4px 0 6px; font-size: 23px; letter-spacing: 0; }
.report-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.report-filters { margin-top: 20px; padding: 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; }
.month-filter, .range-filter { display: flex; align-items: end; gap: 12px; }
.range-filter { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.report-filters label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 700; }
.report-filters input { min-height: 42px; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid #b8c2cf; border-radius: 6px; outline: none; }
.report-filters input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7, 91, 170, .12); }
.report-status { min-height: 22px; margin-top: 15px; color: var(--muted); font-size: 13px; font-weight: 700; }
.report-status.error { color: #b42318; }
.report-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.report-summary article { min-height: 112px; padding: 15px; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: 7px; display: grid; align-content: space-between; }
.report-summary article:nth-child(2) { border-top-color: var(--red); }
.report-summary article:nth-child(3) { border-top-color: var(--green); }
.report-summary article:nth-child(4) { border-top-color: #f0a000; }
.report-summary span, .report-summary small { color: var(--muted); }
.report-summary span { font-size: 12px; font-weight: 750; }
.report-summary strong { margin: 5px 0; font-size: 22px; --metric-font-size:22; overflow-wrap: anywhere; }
.report-summary small { font-size: 11px; }
.report-table-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 24px; padding: 0 2px 11px; }
.report-table-heading h3 { margin: 0; font-size: 17px; }
.report-table-heading span { color: var(--muted); font-size: 12px; font-weight: 700; }

.detail-dialog { width: min(650px, calc(100% - 28px)); max-height: 86vh; padding: 0; color: var(--ink); border: 0; border-radius: 8px; box-shadow: 0 24px 90px rgba(10, 20, 35, .28); }
.detail-dialog::backdrop { background: rgba(12, 20, 32, .58); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 3px 0 0; font-size: 22px; }
.dialog-heading button { width: 38px; height: 38px; color: #667085; background: #fff; border: 1px solid var(--line); border-radius: 50%; font-size: 24px; line-height: 1; }
#detail-content { padding: 8px 22px 18px; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.detail-field { padding: 14px 0; border-bottom: 1px solid #ebeff3; }
.detail-field span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.detail-field strong { display: block; font-size: 14px; line-height: 1.45; }
.dialog-actions { display: flex; gap: 9px; justify-content: flex-end; padding: 15px 22px; background: var(--soft); border-top: 1px solid var(--line); }
.payment-proof-panel { margin: 2px 22px 22px; padding: 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; text-align: center; }
.payment-proof-panel > span { display: block; margin-bottom: 10px; text-align: left; }
.payment-proof-panel p { margin: 0; color: var(--muted); }
.payment-proof-panel img { display: block; width: min(100%, 520px); max-height: 520px; margin: 0 auto; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.payment-review-actions { width: 100%; display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 9px; }
.payment-review-actions input { min-width: 0; min-height: 42px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #aebdca; border-radius: 6px; }
.payment-review-actions input:focus { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 3px rgba(7,91,170,.12); }
.reject-action { min-height: 42px; padding: 9px 15px; color: #a3241b; background: #fff; border: 1px solid #dfa9a5; border-radius: 6px; font-weight: 750; }
.delete-test-action { min-height: 42px; margin-right: auto; padding: 9px 15px; color: #fff; background: #b42318; border: 1px solid #b42318; border-radius: 6px; font-weight: 750; }
.delete-test-action:hover { background: #8f1c13; }
.delete-test-action:disabled { cursor: wait; opacity: .65; }

.article-manager { padding: 22px; }
.article-manager-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.article-manager-heading span { color: var(--blue); font-size: 12px; font-weight: 800; }
.article-manager-heading h2 { margin: 4px 0 6px; font-size: 23px; }
.article-manager-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.article-manager-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 22px; padding-top: 22px; }
.article-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; align-content: start; }
.article-field { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 750; }
.article-field-wide { grid-column: 1 / -1; }
.article-field input, .article-field textarea { width: 100%; min-width: 0; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #b8c2cf; border-radius: 6px; outline: none; resize: vertical; }
.article-field input { min-height: 44px; }
.article-field input:focus, .article-field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7, 91, 170, .12); }
.article-field small { color: var(--muted); font-weight: 500; }
.article-image-preview { height: 220px; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.article-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.article-editor-actions { display: flex; justify-content: flex-end; gap: 9px; }
.article-form-status { min-height: 20px; margin: 0; color: var(--green); font-size: 13px; font-weight: 700; }
.article-form-status.error { color: #b42318; }
.article-list-panel { padding-left: 20px; border-left: 1px solid var(--line); }
.article-list-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.article-list-heading h3 { margin: 0; font-size: 17px; }
.article-list-heading span { color: var(--muted); font-size: 12px; }
.article-admin-list { display: grid; gap: 9px; max-height: 760px; overflow-y: auto; }
.article-admin-item { padding: 13px; border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 6px; }
.article-admin-item.draft { border-left-color: #f0a000; }
.article-admin-item strong { display: block; line-height: 1.35; }
.article-admin-item small { display: block; margin-top: 5px; color: var(--muted); }
.article-admin-actions { display: flex; gap: 7px; margin-top: 11px; }
.article-admin-actions button, .article-admin-actions a { min-height: 34px; padding: 7px 10px; color: var(--blue); background: #fff; border: 1px solid #aebdca; border-radius: 5px; font: inherit; font-size: 12px; font-weight: 750; text-decoration: none; }
.article-list-empty { padding: 36px 15px; color: var(--muted); text-align: center; border: 1px dashed #b8c2cf; border-radius: 7px; }
.article-list-empty strong { color: var(--ink); }
.article-list-empty p { margin: 6px 0 0; font-size: 13px; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-lists { grid-template-columns: 1fr; }
  .report-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-manager-layout { grid-template-columns: 1fr; }
  .article-list-panel { padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

@media (min-width: 901px) and (max-width: 1250px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .login-view { margin-top: 28px; padding: 24px 20px; }
  .login-brand img { width: 64px; height: 64px; }
  .admin-header { align-items: center; padding: 8px 12px; min-height:64px; gap:8px; }
  .admin-brand img { width: 42px; height: 42px; }
  .admin-brand span { display: none; }
  .header-actions button { min-height: 38px; padding: 7px 10px; font-size: 12px; }
  .admin-brand { min-width:0; gap:8px; }
  .admin-brand strong { font-size:14px; }
  .admin-menu-toggle { font-size:12px; padding:8px; }
  .page-heading { padding: 16px 14px 12px; }
  .page-heading h1 { font-size:23px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 9px; padding: 14px 12px; }
  .summary-grid article { min-height: 88px; padding: 10px; overflow-wrap:anywhere; }
  .summary-grid small { font-size:11px; }
  .summary-grid strong { font-size: 21px; --metric-font-size:21; }
  .data-workspace { margin: 0 12px 28px; }
  .data-tabs button { padding: 0 13px; }
  .table-tools { align-items: stretch; flex-direction: column; padding: 14px; }
  .table-tools .secondary-action { width: 100%; }
  .month-groups { gap: 8px; padding: 10px; }
  .month-group summary { min-height: 66px; display: grid; grid-template-columns: minmax(0, 1fr) 28px; gap: 5px 10px; }
  .month-group summary strong { grid-column: 1; grid-row: 1; }
  .month-group summary span { grid-column: 1; grid-row: 2; margin-left: 0; text-align: left; }
  .month-group summary::after { grid-column: 2; grid-row: 1 / span 2; }
  .period-report { padding: 17px 13px; }
  .analytics-panel { padding: 17px 13px; }
  .analytics-bars { height: 150px; gap: 2px; }
  .report-heading { display: grid; }
  .report-heading .secondary-action { width: 100%; }
  .month-filter, .range-filter { align-items: stretch; flex-direction: column; }
  .report-filters label, .report-filters button { width: 100%; }
  .report-summary { gap: 8px; }
  .report-summary article { min-height: 105px; padding: 12px; }
  .report-summary strong { font-size: 19px; --metric-font-size:19; }
  th, td { padding: 11px 10px; }
  .detail-grid { grid-template-columns: 1fr; }
  .payment-review-actions { grid-template-columns: 1fr; }
  .dialog-actions { flex-wrap: wrap; }
  .delete-test-action { width: 100%; margin-right: 0; }
  .article-manager { padding: 17px 13px; }
  .article-manager-heading { display: grid; }
  .article-manager-heading .secondary-action { width: 100%; }
  .article-editor { grid-template-columns: 1fr; }
  .article-field { grid-column: 1; }
  .article-editor-actions { display: grid; }
  .article-image-preview { height: 180px; }
}
