:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --ink: #18211f;
  --muted: #64716d;
  --line: #dce5df;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --red: #b42318;
  --red-bg: #fff0ee;
  --amber: #b54708;
  --amber-bg: #fff6e6;
  --green: #16703a;
  --green-bg: #ebf8ef;
  --blue: #2456a6;
  --blue-bg: #edf4ff;
  --shadow: 0 18px 40px rgba(23, 40, 36, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 28px;
  color: #ffffff;
  background:
    linear-gradient(rgba(12, 68, 64, 0.88), rgba(9, 52, 49, 0.94)),
    url("https://images.unsplash.com/photo-1588964895597-cfccd6e2dbf9?auto=format&fit=crop&w=900&q=80") center/cover;
}

.brand-row,
.panel-header,
.panel-actions,
.toolbar,
.toolbar-actions,
.scan-actions,
.dialog-actions,
.status-pill,
.row-actions {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 14px;
}

.logo {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 5px;
  color: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.72;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
}

h2 {
  font-size: 1.18rem;
}

.metric-grid {
  display: grid;
  gap: 12px;
  margin-top: 42px;
}

.metric {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
}

.metric span {
  font-size: 2.1rem;
  font-weight: 850;
}

.metric small,
.sidebar-note span {
  color: rgba(255, 255, 255, 0.78);
}

.sidebar-note {
  display: grid;
  gap: 5px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.24);
}

.workspace {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.toolbar {
  justify-content: space-between;
  gap: 12px;
}

.search-wrap {
  flex: 1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.toolbar-actions {
  gap: 8px;
}

.app-view[hidden] {
  display: none !important;
}

.home-view {
  display: grid;
}

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

.option-card {
  display: grid;
  gap: 10px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 18px;
  text-align: left;
  box-shadow: var(--shadow);
}

.option-card span {
  color: var(--teal-dark);
  font-size: 1.1rem;
  font-weight: 850;
}

.option-card strong {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 720;
  line-height: 1.4;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--teal-dark);
  font-weight: 850;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(320px, 760px);
  gap: 18px;
  align-items: start;
}

.inventory-view {
  display: grid;
  gap: 18px;
}

.entry-panel,
.review-panel,
.inventory-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.entry-panel,
.review-panel {
  padding: 18px;
}

.entry-panel {
  display: grid;
  gap: 16px;
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
}

.panel-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.scan-zone {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px dashed #9bc8c1;
  border-radius: 8px;
  background: #f0faf8;
}

.scan-copy {
  display: grid;
  gap: 4px;
}

.scan-copy span {
  color: var(--muted);
  font-size: 0.9rem;
}

.scan-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.label-photo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.label-photo-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.ocr-status {
  display: grid;
  gap: 7px;
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.ocr-status[hidden] {
  display: none;
}

.ocr-status progress {
  width: 100%;
  height: 10px;
  accent-color: var(--teal);
}

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

.primary-button,
.ghost-button,
.secondary,
.scan-actions button,
.row-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 800;
}

.primary-button,
.scan-actions button {
  background: var(--teal);
  color: #ffffff;
}

.secondary,
.ghost-button,
.row-actions button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--teal-dark);
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  padding: 0 18px 16px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal-dark);
  padding: 8px 12px;
  font-weight: 850;
}

.tab-button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.date-badge {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 850;
  text-align: center;
  line-height: 1;
}

.date-badge small {
  display: block;
  font-size: 0.68rem;
}

.item-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.item-title strong {
  overflow-wrap: anywhere;
}

.item-title span {
  color: var(--muted);
  font-size: 0.84rem;
}

.inventory-section {
  overflow: hidden;
}

.inventory-section .panel-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.status-pill {
  width: max-content;
  min-height: 30px;
  gap: 7px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.status-pill.expired {
  background: var(--red-bg);
  color: var(--red);
}

.status-pill.soon {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-pill.ok {
  background: var(--green-bg);
  color: var(--green);
}

.status-pill.handled {
  background: var(--blue-bg);
  color: var(--blue);
}

.row-actions {
  gap: 7px;
  flex-wrap: wrap;
}

.empty-state {
  display: grid;
  gap: 5px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #17211f;
  color: #ffffff;
  box-shadow: var(--shadow);
  z-index: 10;
}

.expiry-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.expiry-dialog::backdrop {
  background: rgba(9, 25, 23, 0.38);
}

.expiry-dialog-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 8px;
}

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

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

  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 24px;
  }

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

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

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

  .toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions,
  .scan-actions {
    align-self: stretch;
  }

  .icon-button {
    flex: 1;
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}
