:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #68707c;
  --line: #d9dee5;
  --paper: #fffdf8;
  --surface: #f7f3ea;
  --navy: #14213d;
  --amber: #fca311;
  --green: #2d6a4f;
  --red: #b23a48;
  --blue: #2f5d8c;
  --shadow: 0 18px 45px rgba(20, 33, 61, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

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

button,
a,
label.file-button {
  -webkit-tap-highlight-color: transparent;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  background: var(--navy);
  color: white;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--amber);
  color: var(--navy);
  font-weight: 900;
}

.brand h1,
.brand p,
.topbar h2,
.item-form h3,
.section-heading h3,
.report-card h4,
.item-name {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1;
}

.brand p,
.sync-card p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.segmented,
.nav-tabs {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.nav-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.nav-button {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  text-align: left;
}

.nav-button.is-active {
  background: var(--amber);
  color: var(--navy);
  font-weight: 800;
}

.sync-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sync-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.sync-card.is-cloud .sync-dot {
  background: #52b788;
}

.sync-card.is-error .sync-dot {
  background: var(--red);
}

.sync-refresh {
  min-height: 30px;
  margin-top: 10px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.main-content {
  padding: 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

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

.primary-button,
.secondary-button,
.ghost-button,
.small-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  min-height: 48px;
  padding: 0 16px;
  background: var(--navy);
  color: white;
  font-weight: 850;
}

.secondary-button,
.ghost-button,
.small-button {
  background: white;
  color: var(--navy);
  border: 1px solid var(--line);
}

.secondary-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 750;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
}

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

.stat-card,
.item-form,
.list-panel,
.report-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
}

.stat-card p,
.stat-card span {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.stat-card strong {
  display: block;
  margin: 8px 0;
  font-size: 28px;
}

.workspace {
  display: block;
  align-items: start;
}

.item-form,
.list-panel {
  padding: 20px;
}

.item-form {
  display: grid;
  gap: 14px;
}

.form-header,
.section-heading,
.item-topline,
.list-tools {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.form-header,
.item-topline,
.list-tools {
  align-items: flex-start;
}

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

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: #f3f5f7;
  color: var(--navy);
  font-size: 24px;
  line-height: 1;
}

.section-heading {
  align-items: end;
  margin-bottom: 16px;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #384250;
  font-size: 13px;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
}

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

.list-tools {
  margin-bottom: 20px;
}

.search-field {
  flex: 1;
}

.compact-field {
  width: 180px;
}

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

.item-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.item-image {
  display: grid;
  place-items: center;
  min-height: 112px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e9f1f7, #f8e9d0);
  color: var(--navy);
  font-size: 28px;
  font-weight: 900;
  background-position: center;
  background-size: cover;
}

.item-image.has-image {
  color: transparent;
}

.item-body {
  min-width: 0;
}

.item-name {
  overflow-wrap: anywhere;
  font-size: 18px;
}

.item-meta,
.item-notes {
  margin: 4px 0 0;
  color: var(--muted);
}

.item-notes {
  margin-top: 10px;
  line-height: 1.45;
}

.priority-pill,
.detail-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.priority-pill {
  padding: 0 10px;
  background: #eef2f7;
  color: var(--blue);
  text-transform: capitalize;
}

.priority-pill[data-priority="high"] {
  background: #ffe1df;
  color: var(--red);
}

.priority-pill[data-priority="low"] {
  background: #e8f3ee;
  color: var(--green);
}

.item-details,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.detail-chip {
  padding: 0 9px;
  background: #f3f5f7;
  color: #46515f;
}

.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

.small-button.strong {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.small-button.danger {
  color: var(--red);
}

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

.report-card {
  padding: 16px;
  box-shadow: none;
}

.report-card h4 {
  margin-bottom: 12px;
}

.report-list {
  display: grid;
  gap: 8px;
}

.report-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.report-line small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.empty-state {
  padding: 18px;
  border: 1px dashed #bfc8d3;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 33, 61, 0.46);
}

.modal-panel {
  width: min(720px, 100%);
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(20, 33, 61, 0.28);
}

.hidden,
.visually-hidden {
  display: none !important;
}

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

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

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

  .workspace {
    display: block;
  }
}

@media (max-width: 720px) {
  .main-content,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .list-tools,
  .form-header,
  .section-heading {
    display: grid;
  }

  .topbar-actions,
  .form-row,
  .stats-grid,
  .report-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  #openFormButton {
    grid-column: 1 / -1;
  }

  .compact-field {
    width: 100%;
  }

  .item-card {
    grid-template-columns: 86px 1fr;
  }

  .item-image {
    min-height: 86px;
  }

  .modal-overlay {
    align-items: end;
    padding: 12px;
  }

  .modal-panel {
    max-height: calc(100vh - 24px);
  }
}

@media (max-width: 460px) {
  .item-card {
    grid-template-columns: 1fr;
  }

  .item-image {
    aspect-ratio: 16 / 9;
  }
}
