:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --panel: #ffffff;
  --ink: #202723;
  --muted: #68746d;
  --line: #dce4dd;
  --accent: #17624f;
  --accent-soft: #e2f2ec;
  --warn: #9a5b11;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 38px);
  background: #24312c;
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #a8d9ca;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: clamp(24px, 3vw, 33px);
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
  letter-spacing: 0;
}

button,
.ghost {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0 14px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: #d8e4df;
  font-size: 12px;
  font-weight: 800;
}

.sync-status[data-mode="ok"] {
  color: #9ee0c9;
}

.sync-status[data-mode="working"] {
  color: #ffe1a8;
}

.sync-status[data-mode="error"] {
  color: #ffc1b8;
}

.top-actions .ghost {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.file-label {
  display: grid;
  place-items: center;
}

.file-label input {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  min-height: calc(100vh - 78px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #ebf0eb;
  padding: 14px;
  overflow: auto;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0 11px;
}

input,
select {
  min-height: 40px;
}

textarea {
  min-height: 96px;
  padding-top: 10px;
  resize: vertical;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

.filters label:first-child {
  grid-column: 1 / -1;
}

.bulk,
.summary-strip {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.bulk {
  display: grid;
  gap: 8px;
}

.bulk-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 8px;
}

.summary-strip {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.client-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.client-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.client-row.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.row-check {
  width: 18px;
  min-height: 18px;
  margin-top: 5px;
}

.row-main {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.row-main strong,
.row-main span {
  display: block;
}

.row-main strong {
  font-size: 14px;
}

.row-main span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.row-tags {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.week,
.status,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

.week {
  background: #e8efff;
  color: #27477d;
}

.status {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge {
  background: #fff0d9;
  color: var(--warn);
}

.detail {
  min-width: 0;
  padding: clamp(16px, 3vw, 28px);
  overflow: auto;
}

.empty-state {
  display: grid;
  min-height: 50vh;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.client-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.head-actions {
  display: grid;
  grid-template-columns: 130px 150px;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.wide {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.stack {
  display: grid;
  gap: 8px;
}

.mini-card,
.note-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.mini-card strong,
.mini-card span,
.mini-card small {
  display: block;
}

.mini-card span,
.mini-card small,
.note-card small {
  color: var(--muted);
}

.note-card p {
  margin: 8px 0;
  white-space: pre-wrap;
}

.note-form {
  display: grid;
  grid-template-columns: 140px 140px 1fr auto;
  gap: 10px;
  align-items: end;
}

.checkbox {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkbox input {
  width: 18px;
  min-height: 18px;
}

.wide-field {
  grid-column: span 1;
}

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

.info-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.info-grid span,
.info-grid strong {
  display: block;
}

.info-grid span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  background: #24312c;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
  font-weight: 800;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(25, 34, 30, 0.82);
  padding: 20px;
}

.auth-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.auth-panel h2,
.auth-panel p {
  margin-bottom: 0;
}

.auth-panel button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.auth-panel button.secondary {
  background: #fff;
  color: var(--accent);
}

.auth-panel button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.form-error {
  min-height: 20px;
  color: #a33222;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 55vh;
  }

  .client-head,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .filters,
  .grid,
  .head-actions,
  .note-form,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .sync-status {
    flex-basis: 100%;
  }
}
