:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --ink: #182125;
  --muted: #66727a;
  --line: #d8e0e2;
  --accent: #14716a;
  --accent-strong: #0d544f;
  --accent-soft: #dcefed;
  --blue: #315f9d;
  --violet: #6a5a9b;
  --amber: #9b6616;
  --green: #287047;
  --danger: #b34848;
  --shadow: 0 16px 42px rgba(34, 46, 52, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(318px, 388px) minmax(0, 1fr);
  min-height: 100vh;
}

.read-only .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

.read-only .admin-only {
  display: none !important;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.brand,
.topbar,
.panel-heading,
.section-heading,
.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  justify-content: flex-start;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

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

.brand h1 {
  font-size: 1.18rem;
  line-height: 1.18;
}

.brand p,
.chart-heading p,
.section-heading p,
.summary-strip p,
.muted,
.entry-meta,
.daily-meta {
  color: var(--muted);
}

.brand p {
  margin-top: 3px;
  font-size: 0.88rem;
}

.panel,
.summary-strip > div,
.chart-panel,
.floor-panel,
.history-panel,
.entries-panel,
.controls-band {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  padding: 18px;
  box-shadow: 0 10px 26px rgba(34, 46, 52, 0.06);
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading h2,
.section-heading h2,
.chart-heading h2 {
  font-size: 1rem;
  line-height: 1.25;
}

form {
  display: grid;
  gap: 10px;
}

label {
  color: #334046;
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 113, 106, 0.14);
}

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

.primary-action,
.secondary-action,
.icon-button,
.text-button {
  border-radius: 6px;
  font-weight: 900;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  padding: 0 16px;
}

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

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-action.admin-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.secondary-action.compact {
  align-self: end;
  min-height: 38px;
  padding: 0 12px;
}

.text-button,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.text-button {
  padding: 0 11px;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  place-items: center;
  font-size: 0.95rem;
  line-height: 1;
}

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

.hidden {
  display: none !important;
}

.hidden-control {
  display: none !important;
}

.topbar {
  align-items: flex-start;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e8edf0;
  color: #536168;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mode-badge.admin-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.topbar h2 {
  margin-top: 2px;
  font-size: 2rem;
  line-height: 1.08;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.summary-strip > div {
  min-height: 84px;
  padding: 15px;
}

.summary-strip span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 1.34rem;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-strip p {
  margin-top: 4px;
  font-size: 0.86rem;
}

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

.chart-panel {
  min-width: 0;
  padding: 16px;
  box-shadow: var(--shadow);
}

.chart-heading {
  align-items: flex-start;
  margin-bottom: 12px;
}

.chart-heading p,
.section-heading p {
  margin-top: 3px;
  font-size: 0.86rem;
}

canvas {
  display: block;
  width: 100%;
  height: 286px;
}

.controls-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.floor-panel,
.history-panel,
.entries-panel {
  padding: 16px;
  box-shadow: var(--shadow);
}

.section-heading {
  align-items: flex-start;
  margin-bottom: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: #3d494f;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
}

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

.floor-name {
  font-weight: 900;
}

.stacked-number {
  display: grid;
  gap: 3px;
}

.stacked-number strong {
  font-size: 0.96rem;
}

.stacked-number span {
  color: var(--muted);
  font-size: 0.78rem;
}

.progress-cell {
  min-width: 160px;
}

.percent-cell {
  min-width: 130px;
}

.percent-cell strong {
  display: block;
  font-size: 0.96rem;
}

.percent-cell span {
  color: var(--muted);
  font-size: 0.78rem;
}

.progress-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.84rem;
  font-weight: 900;
}

.meter {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf0;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #3e4b51;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.tag.positive {
  background: #e6f1e9;
  color: var(--green);
}

.tag.warning {
  background: #fff1d6;
  color: var(--amber);
}

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

.content-grid {
  display: grid;
  grid-template-columns: minmax(310px, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.daily-list,
.entry-list {
  display: grid;
  gap: 10px;
}

.daily-row,
.entry-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.daily-row {
  display: grid;
  grid-template-columns: minmax(84px, 120px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.daily-date {
  font-weight: 900;
}

.daily-meta {
  margin-top: 3px;
  font-size: 0.82rem;
}

.daily-bars {
  display: grid;
  gap: 8px;
}

.daily-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #3d494f;
  font-size: 0.82rem;
  font-weight: 900;
}

.entry-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 13px;
}

.entry-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.entry-title-row h3 {
  overflow-wrap: anywhere;
  font-size: 0.98rem;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 7px;
  font-size: 0.86rem;
}

.entry-note {
  margin-top: 8px;
  color: #46545a;
  font-size: 0.88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.entry-actions {
  display: flex;
  gap: 6px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(430px, calc(100vw - 36px));
  padding: 13px 15px;
  border-radius: var(--radius);
  background: #172025;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

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

@media (max-width: 980px) {
  .summary-strip {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .dashboard-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .monthly-plan-list {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .summary-strip,
  .controls-band {
    grid-template-columns: 1fr;
  }

  .monthly-plan-list {
    grid-template-columns: 1fr;
  }

  .daily-row,
  .entry-card {
    grid-template-columns: 1fr;
  }

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

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

  .topbar h2 {
    font-size: 1.55rem;
  }

  canvas {
    height: 238px;
  }
}
