:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f5f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f5f7fb; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #ffffff 0, #f5f7fb 48%, #eef2f8 100%);
}
.login-card {
  width: min(100%, 430px);
  background: #fff;
  border: 1px solid #e4e9f1;
  border-radius: 22px;
  padding: 34px;
  box-shadow: 0 22px 60px rgba(31, 41, 55, .10);
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #1f6f43;
  color: #fff;
  margin-bottom: 20px;
}
h1, h2, p { margin-top: 0; }
.login-card h1 { margin-bottom: 8px; font-size: 28px; }
.login-card > p { color: #667085; margin-bottom: 26px; }

.stack-form { display: grid; gap: 16px; }
.stack-form label, .field { display: grid; gap: 7px; }
.stack-form span, .field-label, .inventory-picker label, .date-range label span { font-size: 13px; font-weight: 700; color: #344054; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  background: #fff;
  color: #101828;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: #2f8f5b; box-shadow: 0 0 0 3px rgba(47, 143, 91, .12); }
textarea { min-height: 96px; resize: vertical; }

.primary-button, .secondary-button, .ghost-button, .nav-button, .preset-button {
  border: 0;
  border-radius: 10px;
  padding: 10px 15px;
  font-weight: 700;
}
.primary-button { background: #1f6f43; color: #fff; }
.primary-button:hover { background: #195c38; }
.secondary-button { background: #e9f5ee; color: #195c38; }
.ghost-button { background: #f2f4f7; color: #344054; }
.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #667085;
  padding: 12px 16px;
  text-decoration: none;
}
.nav-button.active { background: #fff; color: #1f6f43; box-shadow: 0 1px 4px rgba(16, 24, 40, .08); }

.app-shell { width: 80%; margin: 0 auto; padding: 26px 0 50px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.topbar h1 { margin: 3px 0 0; font-size: 28px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.session-email { color: #667085; font-size: 14px; }
.eyebrow { color: #1f6f43; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.main-nav { display: inline-flex; gap: 4px; background: #e9edf3; padding: 4px; border-radius: 13px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid #e4e9f1; border-radius: 16px; padding: 22px; box-shadow: 0 5px 18px rgba(16, 24, 40, .04); }
.inventory-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 16px; }
.inventory-picker { min-width: min(100%, 390px); display: grid; gap: 7px; }
.view-section { display: grid; gap: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin: 3px 0 0; font-size: 21px; }
.fields-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.field-code { color: #98a2b3; font-size: 11px; font-weight: 600; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.form-status { color: #667085; font-size: 14px; }
.form-error { color: #b42318; margin: 0; font-size: 14px; }

.dashboard-heading { margin-bottom: 16px; }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-button { background: #f2f4f7; color: #475467; }
.preset-button.active { background: #e9f5ee; color: #195c38; box-shadow: inset 0 0 0 1px #b7ddc8; }
.date-range { display: grid; grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) auto; align-items: end; gap: 12px; margin-top: 16px; }
.date-range label { display: grid; gap: 7px; }
.range-label { margin-top: 14px; color: #667085; font-size: 14px; font-weight: 600; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { min-height: 155px; display: flex; flex-direction: column; justify-content: center; }
.stat-label { color: #667085; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { margin: 9px 0 7px; font-size: clamp(27px, 3vw, 38px); line-height: 1; font-weight: 800; color: #101828; overflow-wrap: anywhere; }
.stat-note { color: #98a2b3; font-size: 12px; line-height: 1.45; }

.table-card { overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid #eaecf0; border-radius: 12px; }
table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #eaecf0; text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: #f9fafb; color: #475467; font-weight: 800; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.actions-cell { display: flex; gap: 6px; position: sticky; right: 0; background: inherit; }
.table-action { border: 1px solid #d0d5dd; background: #fff; border-radius: 8px; padding: 6px 9px; font-weight: 700; color: #344054; }
.table-action.delete { color: #b42318; }
.badge { background: #f2f4f7; color: #475467; border-radius: 999px; padding: 7px 10px; font-size: 12px; font-weight: 800; }
.empty-table { padding: 28px; text-align: center; color: #667085; }
.empty-state { text-align: center; padding: 40px 22px; }
.empty-state p, .muted { color: #667085; }
.records-heading { margin-bottom: 8px; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 420px; background: #101828; color: #fff; padding: 12px 16px; border-radius: 11px; box-shadow: 0 10px 28px rgba(16, 24, 40, .20); z-index: 50; }

@media (max-width: 1100px) {
  .app-shell { width: 90%; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .app-shell { width: 100%; padding: 12px 10px 34px; }
  .login-screen { padding: 14px; }
  .login-card { padding: 26px 22px; border-radius: 18px; }
  .topbar { align-items: flex-start; padding: 0 4px; margin-bottom: 12px; }
  .topbar h1 { font-size: 22px; line-height: 1.15; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .topbar-actions .ghost-button { min-height: 44px; }
  .session-email { display: none; }
  .main-nav {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    margin: 0 0 12px;
    box-shadow: 0 8px 22px rgba(16, 24, 40, .10);
  }
  .nav-button { min-width: 0; min-height: 54px; padding: 7px 5px; font-size: 12px; line-height: 1.15; text-align: center; white-space: normal; }
  .card { border-radius: 14px; padding: 16px 14px; }
  .inventory-toolbar { align-items: stretch; flex-direction: column; }
  .inventory-picker { min-width: 0; }
  .fields-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; }
  input, select, textarea { min-height: 48px; font-size: 16px; padding: 12px; }
  textarea { min-height: 110px; }
  .primary-button, .secondary-button, .ghost-button, .table-action, .preset-button { min-height: 46px; }
  .inventory-toolbar .secondary-button, .records-heading .primary-button { width: 100%; }
  .records-heading { flex-direction: column; align-items: stretch; }
  .preset-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset-button { padding-inline: 8px; }
  .date-range { grid-template-columns: 1fr; }
  .date-range .primary-button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { min-height: 125px; }
  .stat-value { font-size: 31px; }
  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 15;
    margin: 18px -14px -16px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid #eaecf0;
    backdrop-filter: blur(8px);
  }
  .form-actions .primary-button { flex: 1; min-height: 50px; }
  .form-status { max-width: 48%; font-size: 12px; }
  .table-card { padding-left: 12px; padding-right: 12px; }
  .table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  table { min-width: 1550px; }
  th, td { padding: 10px; }
  .toast { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: none; }
}