:root {
  color-scheme: light;
  --ink: #1b1814;
  --muted: #6f685f;
  --line: #ded4c8;
  --panel: #fffaf2;
  --panel-strong: #f5eadc;
  --field: #fffdf8;
  --brand: #7b160d;
  --brand-dark: #4f0e08;
  --forest: #173b27;
  --moss: #496b37;
  --amber: #c77c24;
  --sky: #dbe9ee;
  --shadow: 0 16px 50px rgba(37, 29, 19, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 59, 39, 0.08), rgba(123, 22, 13, 0.04)),
    #f8f1e7;
  font-family: "Segoe UI", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px;
  color: #fffdf8;
  background: #162419;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-lockup {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-lockup img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.brand-lockup h1,
.topbar h2,
.modal-header h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-lockup h1 {
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #d5c6b1;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: #f8f1e7;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #f7e3c9;
  background: rgba(199, 124, 36, 0.22);
  border-radius: 7px;
}

main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 24px;
  background: rgba(248, 241, 231, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar h2 {
  font-size: clamp(26px, 3vw, 40px);
}

.topbar-actions,
.modal-actions,
.row-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.view {
  padding: 22px 24px 42px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
}

.summary-grid,
.record-grid,
.report-grid,
.calendar-grid {
  display: grid;
  gap: 12px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.record-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.report-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.calendar-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.panel,
.record-card,
.metric-card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(71, 48, 28, 0.08);
}

.panel {
  padding: 16px;
}

.metric-card {
  padding: 14px;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.record-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.record-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.record-card h3,
.panel h3,
.empty-state h3 {
  margin: 0;
}

.record-card dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.record-card dt {
  color: #554c42;
  font-weight: 800;
}

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

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  color: #2c241c;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tag.status {
  color: #fffdf8;
  background: var(--forest);
  border-color: var(--forest);
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  color: #fffdf8;
  background: var(--brand);
  border-color: var(--brand-dark);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.ghost-button,
.icon-button {
  color: var(--ink);
  background: #fffdf8;
  border-color: var(--line);
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--panel-strong);
}

.danger-button {
  color: #fffdf8;
  background: #9b1f16;
  border-color: #76140d;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  padding: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

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

.search-box {
  width: min(100%, 440px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid #cfc2b2;
  border-radius: 8px;
}

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

label {
  display: grid;
  gap: 5px;
  color: #4c4339;
  font-size: 13px;
  font-weight: 800;
}

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

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

.modal {
  width: min(920px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.drawing-modal {
  width: min(1120px, calc(100% - 24px));
}

.modal::backdrop {
  background: rgba(11, 14, 10, 0.58);
}

.modal-frame {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: end;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.drawing-tools {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 92px 140px minmax(200px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.canvas-wrap {
  overflow: auto;
  background: #cfc2b2;
  border: 1px solid var(--line);
  border-radius: 8px;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  touch-action: none;
  background: #fffdf8;
}

.thumb-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.thumb {
  flex: 0 0 92px;
  height: 68px;
  object-fit: cover;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calendar-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.report-table th,
.report-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  color: #4a4036;
  background: var(--panel-strong);
}

.empty-state {
  padding: 28px;
  text-align: center;
}

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

.print-area {
  display: none;
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .brand-lockup {
    grid-template-columns: 110px minmax(0, 1fr);
    align-items: center;
  }

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

  .hero-panel,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

  .install-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .view,
  .topbar,
  .sidebar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand-lockup {
    grid-template-columns: 1fr;
  }

  .nav-list,
  .form-grid,
  .drawing-tools {
    grid-template-columns: 1fr;
  }

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

@media print {
  body {
    background: #fff;
  }

  .app-shell,
  .modal {
    display: none;
  }

  .print-area {
    display: block;
    padding: 24px;
    color: #111;
    font-family: Arial, sans-serif;
  }
}
