:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --ink: #2d2d2d;
  --muted: #6b7280;
  --line: #d9ddd6;
  --surface: #ffffff;
  --soft: #f1ebe2;
  --brand: #1e3a5f;
  --brand-dark: #142840;
  --accent: #c47a3a;
  --accent-soft: #f4e5d6;
  --danger: #9a4f59;
  --shadow: 0 14px 38px rgba(30, 58, 95, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(30, 58, 95, 0.12), transparent 34%),
    linear-gradient(215deg, rgba(196, 122, 58, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

body.locked .topbar,
body.locked .layout {
  display: none;
}

.lock-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

body.locked .lock-screen {
  display: grid;
}

.lock-box {
  display: grid;
  gap: 14px;
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 22px;
}

.lock-box h1,
.lock-box p {
  margin: 0;
}

.fineprint,
.security-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.security-note {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  margin-top: 14px;
  padding: 14px;
}

.security-note strong {
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 48px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.65rem, 4vw, 2.8rem);
}

h2 {
  font-size: 1.05rem;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(30, 37, 43, 0.07);
}

.icon-button:hover,
.tab:hover,
button:hover {
  filter: brightness(0.97);
}

.file-action input {
  display: none;
}

.layout {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto 40px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.summary-strip div,
.metric {
  display: grid;
  gap: 7px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.9);
  padding: 18px;
}

.summary-strip span,
.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.summary-strip strong,
.metric strong {
  overflow-wrap: anywhere;
  font-size: 1.18rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
  padding: 11px 14px;
}

.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.entry-form,
.month-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 18px;
  box-shadow: var(--shadow);
}

.entry-form.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

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

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

textarea {
  resize: vertical;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check input {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  padding: 11px 16px;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.secondary {
  background: var(--soft);
  color: var(--brand-dark);
}

.danger {
  background: #f7e9eb;
  color: var(--danger);
}

.list-header,
.month-tools {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 22px 0 12px;
}

.list-header select,
.list-header input,
.month-tools label {
  max-width: 240px;
}

.inline-controls {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.inline-controls input,
.inline-controls select {
  max-width: 190px;
}

.item-list {
  display: grid;
  gap: 10px;
}

.record {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 16px;
}

.record-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.record-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 850;
}

.pill {
  border-radius: 999px;
  background: #e8edf3;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 850;
  padding: 4px 8px;
}

.record-meta,
.record-notes {
  color: var(--muted);
  line-height: 1.45;
}

.record-actions {
  display: flex;
  align-items: start;
  gap: 8px;
}

.record-actions button {
  padding: 9px 11px;
}

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  display: grid;
  gap: 5px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 16px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .icon-button {
    width: 52px;
    height: 48px;
  }

  .summary-strip,
  .entry-form,
  .entry-form.compact,
  .monthly-grid {
    grid-template-columns: 1fr;
  }

  .record {
    grid-template-columns: 1fr;
  }

  .record-actions {
    justify-content: flex-start;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .tab {
    min-height: 48px;
    white-space: normal;
  }

  .list-header,
  .month-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .list-header select,
  .list-header input,
  .month-tools label,
  .inline-controls input,
  .inline-controls select {
    max-width: none;
  }

  .inline-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  input,
  select,
  textarea,
  button {
    min-height: 46px;
  }
}

@media print {
  .top-actions,
  .tabs,
  .entry-form,
  .list-header,
  #appointments,
  #care,
  #settings {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .layout {
    width: 100%;
  }

  #monthly {
    display: block !important;
  }
}
