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

/* Brand — aligned with www.keystonedataworks.com header; body uses dark surfaces (easier on eyes than black-on-white). */
:root {
  --bg: #0c1124;
  --fg: #e4eaf4;
  --muted: #9aa8c2;
  --accent: #78a6ff;
  --card: #141c38;
  --stroke: #2a3a5c;
  --shadow: 0 8px 20px rgba(4, 10, 30, 0.45);
  --surface: #0a1022;
  --surface-2: #0e162c;
  --text: #e4eaf4;
  --input-bg: #1a2544;
  --table-border: #2d3f66;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% 0%, #121a35 0%, var(--surface) 45%, #080c18 100%);
  min-height: 100vh;
}
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  color: var(--fg);
  background: radial-gradient(100% 60% at 50% 0%, #101736 0%, var(--bg) 80%, #070b19 100%);
  border-bottom: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}
.site-header a { color: var(--accent); text-decoration: none; }
.site-header a:hover { text-decoration: underline; color: var(--fg); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.1rem;
}
.brand-picture {
  display: block;
  flex-shrink: 0;
  line-height: 0;
}
.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: min(200px, 42vw);
  object-fit: contain;
  border-radius: 8px;
}
.container a { color: var(--accent); }
.container a:hover { color: #a8c4ff; }
.nav { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; }
.container { max-width: 960px; margin: 0 auto; padding: 1.25rem; }

.container input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]),
.container select,
.container textarea {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--stroke);
}

.ledger-presets a { white-space: nowrap; }
.ledger-filter.stack { align-items: stretch; }
h1 { font-size: 1.5rem; margin-top: 0; color: var(--fg); }
.lead { font-size: 1.05rem; color: var(--muted); }
.card-list { padding-left: 1.25rem; }
.card-list li { margin-bottom: 0.35rem; }
.muted { color: var(--muted); font-size: 0.95rem; }
.error { color: #a40000; }

.notice {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  max-width: 520px;
}
.notice-success {
  background: #0f2418;
  border: 1px solid #2d6a4a;
  color: #c8efd8;
}
.notice-title { margin: 0 0 0.5rem; font-weight: 600; }

.btn {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  background: var(--card);
  color: var(--fg) !important;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--stroke);
}
.btn:hover { filter: brightness(1.12); border-color: var(--accent); }
a.btn.btn-secondary {
  background: #243354;
  color: var(--fg) !important;
  border-color: var(--stroke);
}
a.btn.btn-secondary:hover { filter: brightness(1.12); border-color: var(--accent); }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  border: 1px solid var(--stroke);
}
.table th, .table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--table-border);
}
.table th { background: rgba(120, 166, 255, 0.12); font-weight: 600; border-bottom-color: var(--stroke); color: var(--fg); }
.table .desc { max-width: 280px; }

.stack { display: flex; flex-direction: column; gap: 0.65rem; max-width: 520px; }
.stack.horizontal { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }
.stack label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 0.9rem; }
.stack input, .stack select, .stack textarea {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
}
.stack .inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1rem; }
.inline-form label { display: flex; flex-direction: column; gap: 0.2rem; font-weight: 600; font-size: 0.9rem; }
.inline-form input { width: 6rem; background: var(--input-bg); color: var(--text); border-color: var(--stroke); }
form.inline { display: inline; }
button.link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font: inherit;
}
button.danger { background: #a40000; color: #fff; border: none; padding: 0.4rem 0.75rem; border-radius: 6px; cursor: pointer; }
.danger-link { color: #a40000 !important; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin-left: 0.35rem; }
.row-actions .link { vertical-align: baseline; }
.total { font-size: 1.1rem; }
.notes { white-space: pre-wrap; }
.print-invoice .invoice-head { display: flex; justify-content: space-between; align-items: baseline; }
.print-invoice .inv-num { font-size: 1.25rem; font-weight: 700; }

tr.line-excluded { background: rgba(255,255,255,0.04); }
tr.line-excluded td { color: var(--muted); }
.tag-gift { font-weight: 600; color: #6b4f00; }

/* Expense ledger filter */
.ledger-filter select.ledger-multi {
  min-width: 16rem;
  min-height: 6.5rem;
  padding: 0.35rem;
}
.ledger-filter .ledger-check {
  align-self: flex-end;
  margin-bottom: 0.25rem;
}
.ledger-filter-hint { margin-top: 0.25rem; margin-bottom: 0.75rem; max-width: 42rem; }
.ledger-actions { margin-bottom: 0.75rem; }

/* Dashboard */
.dashboard-recap { margin-bottom: 1.75rem; }
.dashboard-heading { font-size: 1.1rem; margin: 0 0 0.65rem; color: var(--fg); }
.dashboard-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; }
.dashboard-stat-label { color: var(--muted); font-size: 0.95rem; margin-right: 0.35rem; }
.dashboard-open { margin: 0 0 0.5rem; max-width: 40rem; }
.dashboard-open-loop { margin: 0 0 0.75rem; max-width: 40rem; }
.dashboard-actions { margin: 0.4rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
section.dashboard-recap ul.card-list { margin-top: 0.35rem; margin-bottom: 0; }

/* Dashboard work timer */
.dashboard-clock .clock-actions { align-items: center; }
.dashboard-clock .clock-start-form { margin-bottom: 0; }
.clock-dialog {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 1.25rem;
  max-width: min(32rem, 96vw);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.2));
}
.clock-dialog::backdrop { background: rgba(0,0,0,0.35); }
.clock-dialog-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

/* Reports hub & print previews */
.report-pdf-tip {
  background: rgba(120, 166, 255, 0.08);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  max-width: 44rem;
  color: var(--text);
}
.report-pdf-tip p { margin: 0; }
.report-details { margin: 0 0 1rem; max-width: 44rem; }
.report-details summary { cursor: pointer; font-weight: 600; color: var(--fg); }
.report-details[open] summary { margin-bottom: 0.5rem; }
.report-home-section {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 1rem 1.2rem 1.15rem;
  margin-bottom: 1.25rem;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.report-home-section h2 { margin: 0 0 0.35rem; font-size: 1.15rem; color: var(--fg); }
.report-form { margin-bottom: 0.85rem; }
.report-form:last-child { margin-bottom: 0; }
.report-form-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}
.report-form-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.report-form-fields input { width: 6.5rem; padding: 0.4rem 0.5rem; border: 1px solid var(--stroke); border-radius: 6px; font: inherit; background: var(--input-bg); color: var(--text); }
.report-form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.report-cover .report-h1 {
  margin: 0.25rem 0 0.35rem;
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--fg);
}
.report-cover .report-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.recap-progress-wrap {
  margin: 0.75rem 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: var(--card);
}
.recap-progress-label { margin: 0 0 0.5rem; }
.recap-progress-hint { margin: 0.5rem 0 0; font-size: 0.9rem; }
.recap-progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--stroke);
}
.recap-progress-bar {
  height: 100%;
  width: 35%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #a8c4ff, var(--accent));
  background-size: 200% 100%;
  animation: recap-progress-slide 1.4s ease-in-out infinite;
}
@keyframes recap-progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.recap-copy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}
.recap-copy-actions button {
  font-size: 0.92rem;
}
.recap-workflow-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 52rem;
}
.recap-workflow-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.recap-workflow-form input[type="date"],
.recap-workflow-form input[type="text"]:not(.source-text):not(.time-text),
.recap-workflow-form textarea#client-recap,
.recap-workflow-form textarea[name="generator_notes"] {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
}
.recap-pick-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 0.5rem;
}
.recap-pick-cell {
  width: 2.25rem;
  vertical-align: top;
  padding: 0.35rem 0.5rem 0.35rem 0;
}
.recap-text-cell {
  vertical-align: top;
  padding: 0.35rem 0;
}
.recap-pick-table textarea.source-text,
.recap-pick-table textarea.time-text,
#time-entries-panel textarea.time-text {
  display: block;
  width: 100%;
  min-height: 3rem;
  margin: 0;
  padding: 0.45rem 0.55rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--fg) !important;
  background-color: var(--input-bg) !important;
  border: 1px solid var(--stroke) !important;
  border-radius: 6px;
  box-sizing: border-box;
  -webkit-text-fill-color: var(--fg);
  opacity: 1;
  resize: vertical;
}
.recap-suggestions-panel {
  margin-bottom: 1.25rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: var(--card);
}
.recap-suggestion-heading {
  font-size: 1rem;
  margin: 0.75rem 0 0.5rem;
}
.recap-suggestion-heading:first-child {
  margin-top: 0;
}
.recap-always-icon {
  display: inline-block;
  width: 1.1rem;
  text-align: center;
  color: var(--accent);
  font-weight: bold;
}

/* Backup setup guide */
.backup-steps li { margin-bottom: 0.65rem; }
.backup-field-help { margin: 0; }
.backup-field-help dt {
  font-weight: 600;
  margin-top: 1rem;
  color: var(--fg);
}
.backup-field-help dt:first-child { margin-top: 0; }
.backup-field-help dd {
  margin: 0.35rem 0 0;
  color: var(--muted);
}
.notice-warning {
  background: #2a2210;
  border: 1px solid #8a6d1a;
  color: #f0e6c8;
}
