/* ============================================================
   Warm theme (Things / Todoist feel), layered over styles.css.
   Loaded after styles.css and before tasks.css. Records carry an
   accent color in --proj (set inline from accentColor()).
   ============================================================ */
/* styles.css also sets its tokens on body[data-theme], so match that. */
:root,
body[data-theme="light"],
body[data-theme="dark"] {
  --canvas: #F7F5F2;
  --r-lg: 16px;
  --r-pill: 999px;
  --ease-soft: cubic-bezier(0.2, 0.8, 0.2, 1);
  --shadow-xs: 0 1px 2px rgba(41, 32, 20, 0.05);
  --shadow-sm: 0 1px 3px rgba(41, 32, 20, 0.07), 0 1px 2px rgba(41, 32, 20, 0.04);
  --shadow-md: 0 6px 16px rgba(41, 32, 20, 0.07), 0 2px 4px rgba(41, 32, 20, 0.04);
  --shadow-lg: 0 18px 40px rgba(41, 32, 20, 0.14), 0 4px 10px rgba(41, 32, 20, 0.05);
  /* Numbers stay aligned with tabular figures, without a typewriter font. */
  --font-mono: var(--font-sans);
}

body[data-theme="dark"] {
  --canvas: #0F0F11;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.55);
}

body { font-variant-numeric: tabular-nums; }

/* ── Shell ── */
.main { background: var(--canvas); }

.view-header { padding: 16px 32px; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.view-sub { font-size: 13px; color: var(--fg-3); }

.count-badge {
  padding: 1px 9px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--fg-3);
  font-size: 12px;
  font-weight: 600;
}

/* Sidebar */
.nav-item {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav-item.active { font-weight: 600; box-shadow: inset 0 0 0 1px var(--indigo-border); }
.nav-item:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.nav-section-label { letter-spacing: 0.06em; }

.settings-btn, .btn-export { border-radius: 12px; font-family: var(--font-sans); }
.settings-btn { padding: 9px 0; }

/* ── Buttons ── */
.btn-primary, .btn-secondary, .btn-danger {
  height: 38px;
  border-radius: 12px;
  font-weight: 550;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s var(--ease-soft);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(79, 70, 229, 0.28); }
.btn-primary:active, .btn-secondary:active { transform: translateY(0); }
.btn-secondary { border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-sm); }
.btn-sm { height: 32px; border-radius: 10px; }
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.export-dropdown { border-radius: 14px; padding: 6px; }
.export-dropdown button { border-radius: 8px; }

/* Filters & search as soft pills */
.select-input, .search-box { height: 38px; border-radius: var(--r-pill); box-shadow: var(--shadow-xs); }
.select-input { padding-left: 14px; }
.search-box { padding: 0 14px; }

/* Segmented toggles (view mode, WP groups, agency sections) */
.view-toggle {
  height: 38px;
  padding: 3px;
  gap: 2px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-2);
}
.view-toggle-btn {
  border-radius: var(--r-pill);
  background: transparent;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.view-toggle-btn + .view-toggle-btn { border-left: 0; }
.view-toggle-btn:hover { background: transparent; color: var(--fg); }
.view-toggle-btn.active { background: var(--surface); color: var(--indigo); box-shadow: var(--shadow-sm); }
#agencyViewToggle .view-toggle-btn[data-mode].active { background: var(--surface); }
#agencyViewToggle .view-toggle-btn[data-mode="dashboard"].active { background: var(--surface); color: var(--indigo); }
#agencyViewToggle .view-toggle-btn[data-mode="limit"].active { background: var(--surface); color: var(--emerald); }
#agencyViewToggle .view-toggle-btn[data-mode="invoices"].active { background: var(--surface); color: var(--violet); }
#agencyViewToggle .view-toggle-btn[data-mode="taxes"].active { background: var(--surface); color: var(--amber); }

/* ── Cards: clients & WP sites ── */
.client-grid { gap: 16px; padding: 24px 32px 40px; }

.client-card {
  gap: 14px;
  padding: 18px 18px 14px;
  border-color: var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  transition: transform 0.18s var(--ease-soft), box-shadow 0.18s, border-color 0.18s;
}
.client-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.client-card-header { align-items: center; gap: 12px; }
.client-card-name { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 650; line-height: 1.3; }
.status-dot { margin-top: 0; }

.card-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--proj, var(--indigo)) 15%, var(--surface));
  color: var(--proj, var(--indigo));
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.client-card-url { font-size: 12.5px; color: var(--fg-3); }

.tech-tag {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--proj, var(--indigo)) 10%, var(--surface-2));
  color: var(--fg-2);
  font-size: 12px;
}

.client-card-footer { padding-top: 12px; border-top-color: var(--border-subtle); }
.client-hours { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; }

.card-actions { gap: 2px; }
.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg-4);
  transition: background 0.12s, color 0.12s;
}
.card-btn:hover { color: var(--indigo); background: var(--indigo-soft); }
.card-btn.del:hover { color: var(--rose); background: var(--rose-soft); border: 0; }
.card-btn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }

.empty-state { color: var(--fg-3); }

/* ── Summary / KPI ── */
.hours-summary { gap: 14px; padding: 20px 32px 4px; border-bottom: 0; background: transparent; }

.summary-card, .kpi, .agency-stat-card {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s, transform 0.18s var(--ease-soft);
}
.summary-card:hover, .kpi:hover, .agency-stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.summary-card { padding: 16px 18px; }
.summary-label, .kpi-label { font-size: 12.5px; color: var(--fg-3); }
.summary-value { font-size: 24px; font-weight: 700; }
.summary-value.multi { font-size: 14px; font-weight: 650; }

.kpi { padding: 18px 18px 16px 22px; }
.kpi-flag { left: 0; right: auto; width: 4px; }
.kpi-value { font-size: 28px; font-weight: 700; }
.kpi-sub { font-size: 12px; }

.card-panel {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.panel-title-block .panel-cap { font-size: 13px; font-weight: 550; color: var(--fg-3); }

/* ── Tables ── */
.hours-table-wrap { padding: 20px 32px 40px; }
.hours-table {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  font-size: 13.5px;
}
.hours-table th {
  padding: 13px 14px;
  background: var(--surface);
  color: var(--fg-3);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}
.hours-table td { padding: 14px; border-bottom-color: var(--border-subtle); }
.hours-table tbody tr:hover td { background: color-mix(in srgb, var(--indigo) 3.5%, var(--surface)); }
.hours-table .mono { font-size: 13px; }

.status-badge { border-radius: var(--r-pill); }

/* ── Modals & forms ── */
.modal-overlay { background: rgba(28, 22, 14, 0.38); backdrop-filter: blur(6px); }
.modal {
  width: 680px;
  max-width: calc(100vw - 48px);
  border: 0;
  border-radius: 24px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-subtle);
  animation-duration: 0.22s;
  animation-timing-function: var(--ease-soft);
}
.modal-sm { width: 580px; }
.modal-wide { width: 880px; }
.modal-xl { width: min(1040px, 94vw); }

.modal-header {
  padding: 22px 28px 16px;
  border-bottom: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--indigo) 6%, var(--surface)), var(--surface));
}
.modal-header h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-2);
}
.modal-close:hover { background: var(--surface-3); }
.modal-body { padding: 8px 28px 24px; }
.modal-footer {
  padding: 16px 28px;
  background: var(--surface);
  border-top-color: var(--border-subtle);
  box-shadow: 0 -8px 16px -12px rgba(41, 32, 20, 0.12);
}
.modal-footer .btn-primary, .modal-footer .btn-secondary { min-width: 104px; }

.form-group { margin-bottom: 18px; }
.form-row { gap: 16px; }
.form-hint { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--fg-3); }
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--indigo); }

.form-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 20px;
  padding: 4px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.form-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 7px 14px;
  border: 0;
  border-radius: var(--r-pill);
  font-size: 13px;
  white-space: nowrap;
}
.tab-btn.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }

label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-2);
  text-transform: none;
  letter-spacing: 0;
}
input, textarea, select { border-radius: 12px; padding: 11px 14px; }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }

/* ── Agency ── */
.agency-greeting { padding-top: 24px; }
.agency-greeting h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.agency-stat-card .stat-label { font-size: 12.5px; text-transform: none; letter-spacing: 0; color: var(--fg-3); }
.agency-stat-card .stat-value { font-size: 21px; font-weight: 700; }

.quick-action-btn {
  height: 40px;
  border-radius: 12px;
  font-weight: 600;
  transition: background 0.15s, transform 0.15s var(--ease-soft);
}
.quick-action-btn:hover { filter: none; transform: translateY(-1px); }
.quick-action-btn.blue { background: var(--indigo-soft); color: var(--indigo); }
.quick-action-btn.green { background: var(--emerald-soft); color: var(--emerald); }
.quick-action-btn.purple { background: var(--violet-soft); color: var(--violet); }
.quick-action-btn.blue:hover { background: color-mix(in srgb, var(--indigo) 18%, var(--surface)); }
.quick-action-btn.green:hover { background: color-mix(in srgb, var(--emerald) 18%, var(--surface)); }
.quick-action-btn.purple:hover { background: color-mix(in srgb, var(--violet) 18%, var(--surface)); }

.agency-warning-banner { border-radius: 14px; }

/* ── WP detail month tiles ── */
.month-tile { border-radius: 14px; }

/* ── Login ── */
.auth-card { border-radius: 24px; box-shadow: var(--shadow-lg); }

/* ── Phone / tablet ── */
@media (max-width: 860px) {
  .view-header { padding: 12px 16px; }
  .hours-summary { padding: 16px 16px 0; }
  .hours-table-wrap { padding: 16px 16px 32px; }
  .client-grid { padding: 16px 16px 32px; gap: 12px; }
  .card-actions { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .client-card, .summary-card, .kpi, .agency-stat-card, .btn-primary, .quick-action-btn { transition: none; }
  .client-card:hover, .summary-card:hover, .kpi:hover, .agency-stat-card:hover, .btn-primary:hover { transform: none; }
}

/* Dates and amounts stay on one line in tables */
.hours-table td.mono { white-space: nowrap; }

.auth-screen { background: var(--canvas); }

/* ── WP maintenance: paused sites (client cancelled) ── */
.client-card.is-paused { opacity: 0.55; filter: saturate(0.35); }
.client-card.is-paused:hover { opacity: 0.9; filter: none; }
.wp-card-badges { min-height: 24px; display: flex; align-items: center; }
tr.is-paused td { opacity: 0.5; }
tr.is-paused:hover td { opacity: 0.85; }
.check-row.is-paused { opacity: 0.6; }
.wp-paused-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  margin-left: 8px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11.5px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.wp-card-badges .wp-paused-chip { margin-left: 0; }
.paused-badge { background: var(--amber-soft); color: var(--amber); }
.paused-badge[hidden] { display: none; }
.pause-field { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.pause-field .check-row { padding: 0; font-weight: 600; }
.pause-field .form-hint { margin-left: 0; }

@media (max-width: 860px) {
  /* Full screen on phones (styles.css), so undo the desktop widths here */
  .modal, .modal-sm, .modal-wide, .modal-xl { width: 100%; max-width: none; border-radius: 0; box-shadow: none; }
  .modal-header { padding: 16px 16px 12px; }
}

/* ── WP report: "maintenance done" header, month highlight (as in ConcordSoft) ── */
.done-box { margin-bottom: 18px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--emerald) 7%, var(--surface)); }
.done-box .check-row { padding: 0 0 10px; font-weight: 600; }
.done-box .form-row .form-group { margin-bottom: 0; }
#wpReportModal [hidden] { display: none !important; }
.plugin-row-del { display: inline-flex; align-items: center; justify-content: center; }
.month-tile.done { border-color: color-mix(in srgb, var(--emerald) 40%, var(--border)); background: color-mix(in srgb, var(--emerald) 6%, var(--surface)); }
.month-tile.partial { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); }
.wp-matrix-table input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--emerald); cursor: pointer; }

/* ── WP: filter toolbar and "this month" on cards (as in ConcordSoft) ── */
.wp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.wp-toolbar-filters { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wp-toolbar-filters .select-input { width: 190px; min-width: 0; }
.wp-toolbar-filters .select-input[hidden] { display: none; }
.wp-toolbar-filters .search-box input { width: 190px; }
.date-filter { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-width: 0; }
.date-filter-label { margin: 0; color: var(--fg-3); font-size: 13px; white-space: nowrap; }
.date-filter .select-input { width: 138px; min-width: 0; padding-right: 10px; background-image: none; cursor: text; }
.date-filter-clear { width: 26px; height: 26px; flex-shrink: 0; border: 0; border-radius: var(--r-pill); background: var(--surface-3); color: var(--fg-3); font-size: 16px; line-height: 1; cursor: pointer; transition: background 0.15s, color 0.15s; }
.date-filter-clear:hover, .date-filter-clear:focus-visible { background: var(--indigo-soft); color: var(--indigo); }
.date-filter-clear[hidden] { display: none; }
body[data-theme="dark"] .date-filter .select-input { color-scheme: dark; }
.wp-status-filter .view-toggle-btn { width: auto; gap: 7px; padding: 0 14px; font: 500 13px var(--font-sans); white-space: nowrap; }
.seg-count { padding: 0 7px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--fg-3); font-size: 11px; font-weight: 600; line-height: 18px; }
.view-toggle-btn.active .seg-count { background: var(--indigo-soft); color: var(--indigo); }

#wpSiteGrid .client-card-url { display: block; text-decoration: none; }
#wpSiteGrid .client-card-url:hover { color: var(--indigo); text-decoration: underline; }
#wpSiteGrid .client-card-name { overflow-wrap: anywhere; }
.site-meta { font-size: 12.5px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#wpSiteTable a { color: var(--indigo); text-decoration: none; overflow-wrap: anywhere; }
#wpSiteTable a:hover { text-decoration: underline; }

.month-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.month-check:hover { border-color: var(--emerald); color: var(--emerald); }
.month-check:active { transform: scale(0.9); }
.month-check.on { border-color: var(--emerald); background: var(--emerald); color: #fff; }
.month-check:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.month-state { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--fg-4); white-space: nowrap; }
.month-state.done { color: var(--emerald); font-weight: 600; }

.detail-link { min-width: 0; color: var(--indigo); font-size: 12.5px; text-decoration: none; text-align: right; overflow-wrap: anywhere; }
.detail-link:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .wp-toolbar { flex-wrap: wrap; }
  .wp-toolbar-filters { flex: 1 1 100%; flex-wrap: wrap; }
  .wp-toolbar-filters .select-input { flex: 1 1 0; width: auto; }
  .wp-toolbar-filters .search-box { flex: 1 1 100%; }
  .wp-toolbar-filters .search-box input { width: 100%; }
  .wp-toolbar-filters .date-filter { flex: 1 1 100%; }
  .wp-toolbar-filters .date-filter .select-input { flex: 1 1 0; }
}
@media (max-width: 860px) {
  .wp-toolbar { padding: 10px 16px; }
  .wp-status-filter { max-width: 100%; overflow-x: auto; }
}

/* ── WP: delete a group, move a site ── */
.wp-group-switch .wp-group-del { padding: 0 8px; color: var(--fg-4); }
.wp-group-switch .wp-group-del:hover { color: var(--rose); }
#wpGroupDeleteModal input[type="radio"], #wpMoveModal input[type="radio"] { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--indigo); }
#wpGroupDeleteModal [hidden], #wpMoveModal [hidden] { display: none !important; }
#wgdSummary { margin: 0 0 12px; }
.wgd-target { margin: 2px 0 8px 26px; }
.wgd-warning { margin: 4px 0 0 26px; color: var(--rose); font-weight: 600; }
.wp-move-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }

/* Time spent on maintenance */
.month-grid-total { margin: 0 0 10px; color: var(--fg-3); font-size: 13px; }
.month-grid-total[hidden] { display: none; }
.month-grid-total strong { color: var(--fg); font-weight: 650; }
.matrix-total td { border-top: 2px solid var(--border-strong); background: var(--surface-2); color: var(--fg-2); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
.matrix-total td.matrix-total-label { text-align: left; }

/* Popups */
.detail-section { background: var(--surface); }
.modal-header .btn-danger { border: 1px solid var(--rose-border); background: var(--rose-soft); box-shadow: none; color: var(--rose); }
.modal-header .btn-danger:hover, .modal-header .btn-danger:focus-visible { background: var(--rose); color: var(--surface); filter: none; }
.modal-body .form-group:has(> .check-row) { margin-bottom: 8px; }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Empty screens and loading */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; grid-column: 1 / -1; }
.empty-state .icon { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; margin: 0; border-radius: 20px; background: var(--surface-3); color: var(--fg-3); }
.empty-state p { margin: 0; max-width: 360px; text-align: center; }
.loading-block { padding: 28px 0; color: var(--fg-3); font-size: 13px; text-align: center; animation: loading-fade 1.2s ease-in-out infinite alternate; }
@keyframes loading-fade { from { opacity: 0.45; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .loading-block { animation: none; } }
