:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --panel: #ffffff;
  --ink: #1d2522;
  --muted: #617069;
  --line: #d9dfd8;
  --accent: #216b5c;
  --accent-2: #b65f38;
  --soft: #e8efe8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
body.auth-disabled #login {
  display: none !important;
}
body.auth-disabled #app {
  display: grid !important;
}
button, input, select, textarea {
  font: inherit;
}
button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}
button:hover { filter: brightness(0.96); }
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 20px 70px rgb(28 47 39 / 12%);
}
.login-panel h1,
.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
}
.eyebrow {
  color: var(--accent-2);
  font-weight: 750;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
  font-size: 12px;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.compact-button {
  min-width: 64px;
  padding: 0 12px;
}
.login-panel button { width: 100%; margin-top: 16px; }
.login-panel .password-row button {
  width: auto;
  margin-top: 0;
}
.form-error { color: #9b2424; min-height: 20px; }
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}
.sidebar {
  background: #18231f;
  color: white;
  padding: 22px 16px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand small { color: #b7c8c0; display: block; margin-top: 2px; }
.session-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: #213129;
  color: white;
  border: 1px solid #3a5148;
}
.session-toggle span:first-child { overflow-wrap: anywhere; }
.session-actions {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}
.session-actions button {
  width: 100%;
  color: white;
  border-color: #607a6f;
}
.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #f0c17a;
  color: #18231f;
  border-radius: 8px;
  font-weight: 900;
  font-size: 24px;
}
.sections {
  display: grid;
  align-content: start;
  gap: 8px;
}
.sections button {
  background: transparent;
  color: #dfe9e3;
  text-align: left;
}
.sections button.active {
  background: #294037;
  color: white;
}
.workspace {
  padding: 26px;
  display: grid;
  gap: 18px;
  align-content: start;
}
.app-section { display: none; }
.app-section.active { display: grid; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}
.status-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.status-strip span {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}
.status-strip strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}
.status-strip button {
  min-height: 52px;
}
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  background: transparent;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
}
.tabs button.active {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-color: var(--panel);
  transform: translateY(1px);
}
.panel { display: none; }
.panel.active {
  display: grid;
  gap: 16px;
}
.toolbar,
.take-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}
.wide { grid-column: span 2; }
.wide-row { grid-column: 1 / -1; }
.form-mode {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}
.reading-grid {
  display: grid;
  grid-template-columns: minmax(72px, 0.7fr) repeat(3, minmax(86px, 1fr)) minmax(92px, auto) minmax(104px, 1fr);
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  overflow-x: auto;
}
.reading-head,
.reading-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.reading-label {
  text-transform: none;
  font-size: 13px;
}
.reading-status {
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  min-height: 18px;
}
.timer-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.timer-controls {
  display: grid;
  grid-template-columns: 80px auto auto;
  gap: 8px;
}
.timer-display {
  min-width: 112px;
  min-height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 28px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.timer-display.done {
  background: #f6e7df;
  color: #8a3f24;
}
.timer-state {
  min-width: 86px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.panel-head h2 {
  font-size: 16px;
  margin: 0;
}
.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  display: inline-block;
}
.legend-sys { background: var(--accent-2); }
.legend-dia { background: var(--accent); }
.bp-chart {
  min-height: 220px;
  overflow-x: auto;
}
.bp-chart svg {
  display: block;
  min-width: 620px;
  width: 100%;
  height: auto;
}
.grid-line {
  stroke: var(--line);
  stroke-width: 1;
}
.axis-label,
.date-label {
  fill: var(--muted);
  font-size: 11px;
}
.line-sys,
.line-dia {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.line-sys { stroke: var(--accent-2); }
.line-dia { stroke: var(--accent); }
.dot-sys { fill: var(--accent-2); }
.dot-dia { fill: var(--accent); }
.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.check {
  min-height: 40px;
  display: flex;
  flex-direction: row;
  align-items: center;
}
.check input { width: auto; min-height: auto; }
.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}
tr:last-child td { border-bottom: 0; }
.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.icon-btn {
  min-height: 32px;
  width: 32px;
  padding: 0;
  background: var(--soft);
  color: var(--ink);
}
.danger { color: #9b2424; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  background: var(--soft);
  color: var(--muted);
}
.reading-line {
  display: grid;
  grid-template-columns: 18px 78px 64px;
  gap: 8px;
  align-items: baseline;
  min-height: 24px;
}
.reading-line span,
.reading-line small,
td small {
  color: var(--muted);
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}
.take-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}
.take-panel h2 {
  margin: 0;
  font-size: 18px;
}
.mini-list {
  display: grid;
  gap: 8px;
}
.mini-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  color: var(--muted);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}
.mini-item strong {
  color: var(--ink);
  display: block;
}
.shopping-form {
  display: grid;
  grid-template-columns: minmax(190px, 1.7fr) minmax(110px, 0.7fr) minmax(140px, 0.9fr) minmax(150px, 1fr) minmax(170px, 1.2fr) auto auto;
  gap: 12px;
  align-items: end;
}
.shopping-list {
  display: grid;
  gap: 8px;
}
.shopping-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 68px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.shopping-check {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: white;
  color: white;
  font-size: 20px;
  line-height: 1;
}
.shopping-item.completed .shopping-check {
  background: var(--accent);
}
.shopping-item.store-yellow,
.regular-item.store-yellow { background: #fff9d6; border-color: #eadb8c; }
.shopping-item.store-green,
.regular-item.store-green { background: #eaf7ea; border-color: #b7d9b7; }
.shopping-item.store-blue,
.regular-item.store-blue { background: #eaf5fb; border-color: #b7d4e5; }
.shopping-item.store-pink,
.regular-item.store-pink { background: #fbeaf0; border-color: #dfb8c5; }
.shopping-item.store-purple,
.regular-item.store-purple { background: #f2ecfa; border-color: #cdbfe0; }
.shopping-item.store-gray,
.regular-item.store-gray { background: #f1f3f2; border-color: #cbd0cd; }
.shopping-item-main {
  min-width: 0;
}
.shopping-item-main strong {
  display: block;
  font-size: 17px;
}
.shopping-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}
.shopping-meta span:not(:last-child)::after {
  content: "·";
  margin-left: 7px;
}
.shopping-store {
  color: var(--accent);
  font-weight: 700;
}
.shopping-item.completed {
  background: #f0f2ef;
}
.shopping-item.completed .shopping-item-main {
  opacity: 0.58;
  text-decoration: line-through;
}
.regulars-panel {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.regulars-panel .panel-head {
  margin: 0;
}
.regulars-panel h2 {
  margin: 4px 0 0;
  font-size: 20px;
}
.regular-form {
  display: grid;
  grid-template-columns: minmax(170px, 1.4fr) minmax(90px, 0.6fr) minmax(120px, 0.9fr) minmax(140px, 1fr) minmax(150px, 1.1fr) auto auto;
  gap: 8px;
}
.stores-manager {
  margin-top: 10px;
  color: var(--muted);
}
.stores-manager summary {
  width: fit-content;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.stores-manager-body {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.store-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 8px;
  align-items: end;
}
.store-color-picker legend { margin-bottom: 4px; }
.store-color-picker .note-color { width: 25px; height: 25px; }
.stores-list {
  display: grid;
  gap: 6px;
}
.store-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.store-name {
  display: flex;
  align-items: center;
  gap: 9px;
}
.store-name .note-color {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}
.regulars-list {
  display: grid;
  gap: 8px;
}
.regular-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: 7px;
}
.regular-add {
  min-height: 32px;
  padding: 0 10px;
}
.regulars-empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
}
.notes-search-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.note-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2fr;
  gap: 12px;
  align-items: start;
}
.note-content-field {
  grid-row: span 3;
}
.note-content-field textarea {
  min-height: 210px;
}
.color-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
}
.color-picker legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.color-picker label {
  display: block;
}
.color-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.note-color {
  display: block;
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}
.color-picker input:checked + .note-color {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px white inset;
}
.note-color.yellow,
.note-yellow { background: #fff2a8; }
.note-color.green,
.note-green { background: #cfeccf; }
.note-color.blue,
.note-blue { background: #cfe7f6; }
.note-color.pink,
.note-pink { background: #f5d1dc; }
.note-color.purple,
.note-purple { background: #e3d7f4; }
.note-color.gray,
.note-gray { background: #e2e5e3; }
.note-pin-check {
  justify-self: start;
}
.note-form-actions {
  display: flex;
  gap: 8px;
}
.notes-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.notes-grid > .empty-state {
  grid-column: 1 / -1;
}
.note-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 88px;
  padding: 0 14px 0 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.note-row:hover,
.note-row:focus-visible {
  border-color: #aebbb4;
  box-shadow: 0 3px 12px rgb(29 37 34 / 8%);
  outline: none;
}
.note-row-color {
  display: block;
  align-self: stretch;
}
.note-row-main {
  min-width: 0;
  padding: 12px 0;
}
.note-row-title {
  display: flex;
  gap: 8px;
  align-items: center;
}
.note-row h2 {
  margin: 0;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.note-pinned {
  color: var(--accent-2);
  font-size: 13px;
}
.note-row p {
  margin: 5px 0 4px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.note-row time {
  color: #75827c;
  font-size: 11px;
}
.note-row-arrow {
  align-self: center;
  color: var(--muted);
  font-size: 30px;
  font-weight: 300;
}
.note-viewer {
  width: min(760px, calc(100% - 28px));
  max-width: calc(100vw - 28px);
  max-height: min(82vh, 900px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  box-shadow: 0 24px 80px rgb(0 0 0 / 28%);
}
.note-viewer::backdrop {
  background: rgb(12 20 17 / 58%);
}
.note-viewer-shell {
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr);
  max-height: min(82vh, 900px);
}
.note-viewer-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.note-viewer-head > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px 10px;
  align-items: center;
  min-width: 0;
}
.note-viewer-color {
  width: 14px;
  height: 36px;
  grid-row: span 2;
  border-radius: 999px;
}
.note-viewer h2 {
  margin: 0;
  font-size: 24px;
  overflow-wrap: anywhere;
  min-width: 0;
}
.note-viewer time {
  color: var(--muted);
  font-size: 12px;
}
.note-viewer-close {
  align-self: start;
}
.note-viewer-content {
  padding: 20px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
  font-size: 18px;
}
.note-viewer-actions {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fafbf9;
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .sections {
    display: flex;
    overflow-x: auto;
  }
  .sections button {
    white-space: nowrap;
    text-align: center;
  }
  .topbar { display: grid; }
  .status-strip { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .wide { grid-column: span 2; }
  .wide-row { grid-column: 1 / -1; }
  .split { grid-template-columns: 1fr; }
  .timer-panel { grid-template-columns: 1fr; }
  .shopping-form { grid-template-columns: 1fr 1fr; }
  .shopping-name,
  .shopping-notes { grid-column: span 2; }
  .regular-form { grid-template-columns: 1fr 1fr; }
  .store-form { grid-template-columns: 1fr 1fr; }
  .note-form { grid-template-columns: 1fr; }
  .note-content-field { grid-row: auto; }
}
@media (max-width: 560px) {
  .workspace { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .wide-row { grid-column: auto; }
  .reading-grid {
    grid-template-columns: minmax(72px, 0.7fr) repeat(3, minmax(86px, 1fr)) minmax(92px, auto) minmax(104px, 1fr);
  }
  .timer-controls { grid-template-columns: 1fr; }
  .shopping-form { grid-template-columns: 1fr; }
  .shopping-name,
  .shopping-notes { grid-column: auto; }
  .shopping-item { align-items: start; }
  .regular-form { grid-template-columns: 1fr; }
  .store-form { grid-template-columns: 1fr; }
  .regular-item { grid-template-columns: 1fr; }
  .regular-item .row-actions { justify-content: flex-start; }
  .regulars-panel .panel-head { align-items: stretch; flex-direction: column; }
  .notes-search-wrap { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: 1fr; }
  .note-viewer {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: min(88dvh, 760px);
    max-height: 88dvh;
    margin: auto 8px 0;
    border-radius: 12px 12px 0 0;
  }
  .note-viewer-shell {
    width: 100%;
    height: 100%;
    max-height: 88dvh;
  }
  .note-viewer-head {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }
  .note-viewer-close {
    position: absolute;
    top: 12px;
    right: 12px;
    min-height: 36px;
  }
  .note-viewer-head > div {
    padding-right: 76px;
  }
  .note-viewer h2 {
    font-size: 27px;
    line-height: 1.2;
  }
  .note-viewer-content {
    padding: 18px 16px;
    font-size: 19px;
    line-height: 1.65;
    overflow-x: hidden;
  }
  .note-viewer-actions {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 12px;
  }
  .note-viewer-actions button {
    flex: 1 0 auto;
    min-width: max-content;
  }
}
