:root {
  --blue: #111111;
  --blue-2: #3f3f46;
  --ink: #1f1f1f;
  --muted: #6b7280;
  --line: #d1d5db;
  --soft: #f3f4f6;
  --white: #ffffff;
  --success: #3f3f46;
  --warning: #6b7280;
  --danger: #111111;
  --control-color: #000000;
  --active-field: #eeeeee;
  --font-main: Arial;
  --base-font-size: 16px;
  --title-size: 22px;
  --button-size: 46px;
  --radius: 8px;
  --border-width: 1px;
  --strong-border-width: 2px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-main), Arial, Helvetica, sans-serif;
  font-size: var(--base-font-size);
  color: var(--ink);
  background: var(--soft);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: var(--blue);
  color: var(--white);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.7);
  font-weight: 800;
  letter-spacing: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.brand span {
  display: block;
  color: #d1d5db;
  margin-top: 3px;
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: var(--button-size);
  border: 0;
  color: #e5e7eb;
  background: transparent;
  text-align: left;
  padding: 12px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.nav-item span {
  width: 24px;
  text-align: center;
  font-weight: 700;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: inline-block;
  background-color: currentColor;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
}

.nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  background: #111111;
  color: #ffffff;
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
  transition: opacity 0.15s ease;
}

.nav-item:hover::after,
.nav-item:focus-visible::after,
.nav-item.show-label::after {
  opacity: 1;
}

.home-icon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 10.8 12 3l9 7.8v9.7a1 1 0 0 1-1 1h-5.2v-6.4H9.2v6.4H4a1 1 0 0 1-1-1z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 10.8 12 3l9 7.8v9.7a1 1 0 0 1-1 1h-5.2v-6.4H9.2v6.4H4a1 1 0 0 1-1-1z'/%3E%3C/svg%3E");
}

.clients-icon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 12a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4Zm-8 9a8 8 0 0 1 16 0z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 12a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4Zm-8 9a8 8 0 0 1 16 0z'/%3E%3C/svg%3E");
}

.add-icon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 4h4v6h6v4h-6v6h-4v-6H4v-4h6z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 4h4v6h6v4h-6v6h-4v-6H4v-4h6z'/%3E%3C/svg%3E");
}

.calendar-icon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 3h2v2h10V3h2v2h2v18H3V5h2zm0 8v8h14v-8z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 3h2v2h10V3h2v2h2v18H3V5h2zm0 8v8h14v-8z'/%3E%3C/svg%3E");
}

.search-icon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5 4a6.5 6.5 0 0 1 5.1 10.5l4.2 4.2-2.8 2.8-4.2-4.2A6.5 6.5 0 1 1 10.5 4Zm0 4a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5 4a6.5 6.5 0 0 1 5.1 10.5l4.2 4.2-2.8 2.8-4.2-4.2A6.5 6.5 0 1 1 10.5 4Zm0 4a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z'/%3E%3C/svg%3E");
}

.reports-icon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 3h14v18H5zm4 5h6V6H9zm0 4h10v-2H9zm0 4h10v-2H9z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 3h14v18H5zm4 5h6V6H9zm0 4h10v-2H9zm0 4h10v-2H9z'/%3E%3C/svg%3E");
}

.settings-icon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5 2h3l.5 2.4a8 8 0 0 1 1.8.8l2.1-1.3 2.1 2.1-1.3 2.1c.4.6.6 1.2.8 1.8l2.4.5v3l-2.4.5a8 8 0 0 1-.8 1.8l1.3 2.1-2.1 2.1-2.1-1.3a8 8 0 0 1-1.8.8l-.5 2.4h-3l-.5-2.4a8 8 0 0 1-1.8-.8l-2.1 1.3-2.1-2.1 1.3-2.1a8 8 0 0 1-.8-1.8L2 13.5v-3l2.4-.5c.2-.6.5-1.2.8-1.8L3.9 6.1l2.1-2.1 2.1 1.3c.6-.4 1.2-.6 1.8-.8zM12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5 2h3l.5 2.4a8 8 0 0 1 1.8.8l2.1-1.3 2.1 2.1-1.3 2.1c.4.6.6 1.2.8 1.8l2.4.5v3l-2.4.5a8 8 0 0 1-.8 1.8l1.3 2.1-2.1 2.1-2.1-1.3a8 8 0 0 1-1.8.8l-.5 2.4h-3l-.5-2.4a8 8 0 0 1-1.8-.8l-2.1 1.3-2.1-2.1 1.3-2.1a8 8 0 0 1-.8-1.8L2 13.5v-3l2.4-.5c.2-.6.5-1.2.8-1.8L3.9 6.1l2.1-2.1 2.1 1.3c.6-.4 1.2-.6 1.8-.8zM12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8z'/%3E%3C/svg%3E");
}

.nav-item.active,
.nav-item:hover {
  background: var(--blue-2);
  color: var(--white);
}

main {
  padding: 24px;
  overflow: auto;
}

.topbar {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
  padding-top: 34px;
  margin-bottom: 22px;
}

.topbar > div {
  flex: 1;
  text-align: left;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.top-logo {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  min-height: 58px;
  margin-bottom: 5px;
  color: #000000;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-logo img {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: contain;
  border: var(--border-width) solid var(--line);
  background: #050505;
}

.top-logo span {
  position: absolute;
  right: 0;
  top: 0;
  min-height: 58px;
  max-width: calc(100% - 74px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #000000;
  color: #ffffff;
  border-radius: 14px;
  border: var(--border-width) solid var(--line);
}

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

h1 {
  font-size: var(--title-size);
}

h2 {
  font-size: 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.primary-action,
.secondary-action {
  min-height: var(--button-size);
  border-radius: var(--radius);
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-action {
  background: var(--blue);
  color: var(--white);
}

.primary-action:active,
.secondary-action:active,
.chip:active,
.nav-item:active {
  transform: translateY(1px);
}

.secondary-action {
  background: var(--white);
  color: var(--blue);
  border-color: var(--line);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.dashboard-filters {
  margin-bottom: 16px;
}

.stat-card,
.panel {
  background: var(--white);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 34px;
  color: var(--blue);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid,
.stack {
  display: grid;
  gap: 12px;
}

.row,
.search-row,
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  padding: 13px 14px;
  min-height: 48px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--line);
  background: var(--active-field);
}

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

.large-text {
  min-height: 130px;
}

.list,
.items-list {
  display: grid;
  gap: 12px;
}

.add-item-footer {
  margin-top: 14px;
  display: grid;
}

.list-item {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  display: grid;
  gap: 8px;
}

.list-item strong {
  color: var(--blue);
}

.list-item small {
  color: var(--muted);
  line-height: 1.5;
}

.item-actions,
.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-actions button {
  min-height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--blue);
  font-weight: 700;
  padding: 0 12px;
}

.item-actions button:first-child,
.item-actions button:nth-child(2) {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

.survey-form {
  max-width: 1180px;
}

.survey-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  background: var(--soft);
  color: var(--blue);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-weight: 800;
}

.item-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.survey-item {
  border: var(--strong-border-width) solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: color-mix(in srgb, var(--soft) 42%, var(--white));
  scroll-margin-top: 90px;
}

.item-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.item-titlebar h3 {
  margin-top: 8px;
  color: var(--blue);
  font-size: 20px;
}

.mini-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.mini-section h4 {
  font-size: 16px;
}

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

.file-label input {
  display: none;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.photo-card {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
}

.photo-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.photo-card div {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.empty-note {
  margin: 0;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--white);
}

.measure-row {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 0.7fr) 0.6fr 42px;
  gap: 8px;
}

.icon-button {
  min-height: 48px;
  border-radius: var(--radius);
  border: var(--border-width) solid var(--line);
  color: var(--danger);
  background: var(--white);
  font-weight: 900;
  padding: 0 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  border: var(--border-width) solid var(--line);
  background: var(--white);
  color: var(--blue);
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-weight: 700;
}

.chip.active {
  background: var(--blue-2);
  color: var(--white);
}

canvas {
  width: 100%;
  background: #f9fafb;
  border: 1px dashed #9ca3af;
  border-radius: var(--radius);
  touch-action: none;
}

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

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

.voice-note-card {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 2fr) auto;
  gap: 10px;
  align-items: center;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  padding: 10px;
}

.voice-note-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.voice-note-card audio {
  width: 100%;
}

.signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.actions-row {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.survey-export-panel {
  margin-top: 14px;
}

.survey-export-panel:empty {
  display: none;
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.export-actions button {
  min-height: var(--button-size);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
}

.progress-list {
  display: grid;
  gap: 18px;
}

.progress-list span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
}

.calendar-header {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
}

.calendar-hint {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
}

.month-arrow {
  min-width: 38px;
  min-height: 38px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  display: grid;
  place-items: center;
  padding: 0;
}

.calendar-title-button {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  min-height: 46px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
}

#calendarMonthLabel {
  font-size: 22px;
  color: var(--ink);
}

#calendarYearLabel {
  font-size: 22px;
  color: var(--ink);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin: 12px 0 18px;
}

.calendar-weekday {
  text-align: center;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  padding: 6px 0;
}

.calendar-cell {
  min-height: 76px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 8px 4px;
}

.calendar-cell strong {
  font-size: 19px;
}

.calendar-cell span {
  display: inline-flex;
  min-width: 24px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--blue-2);
  color: var(--white);
  font-size: 12px;
  font-weight: 800;
}

.calendar-cell.has-events {
  border-color: var(--blue-2);
  box-shadow: inset 0 0 0 1px var(--blue-2);
}

.calendar-cell.selected {
  background: var(--blue);
  color: var(--white);
}

.calendar-cell.selected span {
  background: var(--white);
  color: var(--blue);
}

.muted-cell {
  opacity: 0.35;
  pointer-events: none;
}

.calendar-day-title {
  margin-top: 8px;
}

.calendar-preview {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  padding: 12px;
  margin-bottom: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.calendar-picker-box {
  max-width: 560px;
}

.picker-grid {
  display: grid;
  gap: 8px;
}

.month-picker {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
}

.year-picker {
  grid-template-columns: repeat(4, 1fr);
}

.picker-option {
  min-height: 44px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
}

.picker-option.active {
  background: var(--blue);
  color: var(--white);
}

.year-picker-row {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 10px;
  margin: 16px 0 10px;
  text-align: center;
}

.preview-empty,
.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.preview-empty strong,
.preview-head strong {
  color: var(--blue);
}

.preview-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.preview-card {
  display: grid;
  gap: 4px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--soft);
}

.preview-card strong {
  color: var(--blue);
}

.preview-card span {
  font-weight: 700;
}

.preview-card small {
  color: var(--muted);
  line-height: 1.35;
}

progress {
  width: 100%;
  height: 16px;
  accent-color: var(--control-color);
}

input[type='range'],
input[type='checkbox'] {
  accent-color: var(--control-color);
}

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

.settings-grid label {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--soft);
}

.settings-grid label span {
  font-weight: 700;
}

.settings-grid input,
.settings-grid select {
  max-width: 260px;
}

.settings-grid input[type='checkbox'] {
  width: 22px;
  min-height: 22px;
}

.backup-panel {
  margin-top: 18px;
  border-top: var(--border-width) solid var(--line);
  padding-top: 18px;
}

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

.backup-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.icon-setting {
  grid-column: span 2;
}

.icon-setting img {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--white);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(80px);
  background: var(--blue);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius);
  opacity: 0;
  transition: 0.2s ease;
  pointer-events: none;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.45);
}

.modal.show {
  display: flex;
}

.modal-box {
  width: min(100%, 620px);
  max-height: 88vh;
  overflow: auto;
  background: var(--white);
  color: var(--ink);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

body.dark {
  --ink: #f3f4f6;
  --muted: #d1d5db;
  --blue: #f3f4f6;
  --blue-2: #52525b;
  --white: #18181b;
  color-scheme: dark;
}

body.dark .sidebar,
body.dark .primary-action,
body.dark .item-actions button:first-child,
body.dark .item-actions button:nth-child(2),
body.dark #toast {
  background: #0a0a0a;
  color: #ffffff;
}

body.dark .secondary-action,
body.dark .item-actions button,
body.dark .chip,
body.dark input,
body.dark select,
body.dark textarea,
body.dark .calendar-cell,
body.dark .empty-note,
body.dark .photo-card,
body.dark .preview-card,
body.dark .settings-grid label {
  background: #1f1f1f;
  color: #f3f4f6;
}

body.dark input::placeholder,
body.dark textarea::placeholder {
  color: #d1d5db;
}

body.dark input:focus,
body.dark select:focus,
body.dark textarea:focus {
  outline: none;
  border-color: var(--line);
  background: var(--active-field);
  color: #111111;
}

body.dark .stat-card strong,
body.dark .list-item strong,
body.dark .item-titlebar h3,
body.dark .preview-card strong,
body.dark .preview-empty strong,
body.dark .preview-head strong {
  color: #ffffff;
}

body.dark .top-logo {
  color: #ffffff;
}

body.dark canvas {
  background: #1f1f1f;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding-bottom: 92px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.14);
  }

  .brand {
    display: none;
  }

  .main-nav {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow-x: visible;
    gap: 2px;
    scrollbar-width: none;
  }

  .nav-item {
    min-width: 0;
    min-height: 58px;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 3px;
    font-size: 10px;
    padding: 7px 2px;
    line-height: 1.1;
    font-size: 0;
  }

  .nav-item::after {
    left: 50%;
    top: auto;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
  }

  .nav-item span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
  }

  main {
    padding: 12px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    margin: -12px -12px 14px;
    padding: 58px 12px 12px;
    min-height: 112px;
    background: color-mix(in srgb, var(--soft) 94%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 0;
  }

  .top-logo img {
    left: 12px;
    width: 58px;
    height: 58px;
  }

  .top-logo span {
    right: 12px;
    min-height: 58px;
    max-width: calc(100% - 94px);
  }

  .topbar .primary-action {
    min-width: 94px;
  }

  h1 {
    font-size: var(--title-size);
    line-height: 1.16;
  }

  h2 {
    font-size: 17px;
  }

  .stats-grid,
  .split-layout,
  .signatures,
  .settings-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .measure-row {
    grid-template-columns: 1fr 1fr;
  }

  .survey-item {
    padding: 12px;
  }

  .item-toolbar {
    position: sticky;
    top: 75px;
    z-index: 2;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  }

  .item-toolbar .primary-action {
    width: 100%;
  }

  .panel {
    padding: 14px;
  }

  input,
  select,
  textarea {
    min-height: 54px;
    font-size: 16px;
    padding: 14px;
  }

  .primary-action,
  .secondary-action {
    min-height: 54px;
    padding: 0 14px;
  }

  .list-item,
  .survey-item,
  .photo-card,
  .empty-note {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  }

  .item-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-actions button {
    min-height: 48px;
    width: 100%;
  }

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

  .photo-card img {
    height: 230px;
  }

  .button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .button-group .secondary-action,
  .actions-row .primary-action,
  .actions-row .secondary-action {
    width: 100%;
  }

  .actions-row {
    position: sticky;
    bottom: 88px;
    z-index: 3;
    display: grid;
    grid-template-columns: 1fr;
    padding: 10px;
    margin: 18px -10px -6px;
    background: color-mix(in srgb, var(--white) 96%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
  }

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

  .chip {
    min-height: 50px;
    white-space: normal;
    line-height: 1.2;
  }

  canvas {
    min-height: 210px;
  }

  .mini-section h4 {
    font-size: 17px;
  }

  .empty-note {
    font-size: 15px;
    line-height: 1.45;
  }

  .settings-grid label {
    display: grid;
    align-items: start;
  }

  .settings-grid input,
  .settings-grid select {
    max-width: none;
  }

  .backup-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .icon-setting {
    grid-column: span 1;
  }
}

@media (max-width: 560px) {
  .panel-header,
  .item-titlebar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    align-items: flex-end;
    flex-direction: row;
  }

  h1 {
    font-size: var(--title-size);
  }

  .row,
  .search-row,
  .filter-grid {
    grid-template-columns: 1fr;
  }

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

  .measure-row {
    grid-template-columns: 1fr;
  }

  .voice-note-card {
    grid-template-columns: 1fr;
  }

  .export-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-grid {
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-card strong {
    font-size: 28px;
  }

  .survey-section {
    margin-top: 14px;
    padding-top: 14px;
  }

  .survey-item {
    margin-inline: -4px;
  }

  .item-titlebar h3 {
    font-size: 18px;
  }

  .panel-header {
    gap: 8px;
  }

  .calendar-grid {
    gap: 5px;
  }

  .calendar-cell {
    min-height: 58px;
    padding: 5px 2px;
  }

  .calendar-cell strong {
    font-size: 16px;
  }

  .calendar-cell span {
    min-width: 20px;
    min-height: 20px;
  }

  .calendar-weekday {
    font-size: 11px;
  }
}
