:root {
  --bg: #f4ead0;
  --surface: rgba(255, 250, 240, 0.82);
  --surface-strong: rgba(255, 252, 244, 0.94);
  --surface-soft: rgba(247, 238, 214, 0.78);
  --border: rgba(91, 60, 16, 0.14);
  --border-strong: rgba(91, 60, 16, 0.22);
  --text: #251b10;
  --muted: #5c482d;
  --accent: #234c41;
  --accent-soft: #dceae5;
  --accent-highlight: #d9a24b;
  --accent-earth: #9e5f2b;
  --danger: #8e4020;
  --warning: #a36b1c;
  --shadow: 0 28px 90px rgba(62, 40, 7, 0.16);
  --shadow-soft: 0 16px 34px rgba(62, 40, 7, 0.09);
  --radius: 18px;
  --radius-sm: 14px;
  --font-display: "Be Vietnam Pro", "Avenir Next", "Segoe UI", sans-serif;
  --font-body: "Be Vietnam Pro", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.88), transparent 24%),
    radial-gradient(circle at 85% 18%, rgba(217, 162, 75, 0.26), transparent 24%),
    radial-gradient(circle at 76% 82%, rgba(35, 76, 65, 0.18), transparent 28%),
    linear-gradient(145deg, #f9f0db 0%, #ecd39a 48%, #c78632 100%);
}

::selection {
  color: #fff8ed;
  background: rgba(35, 76, 65, 0.88);
}

body {
  position: relative;
  font-variant-numeric: tabular-nums lining-nums;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(10px);
}

body::before {
  top: 84px;
  right: -90px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 246, 221, 0.55), transparent 66%);
}

body::after {
  bottom: 18px;
  left: -120px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(35, 76, 65, 0.12), transparent 70%);
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked #app-shell {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.grain-background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.46;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.42) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 22%, rgba(255, 255, 255, 0.22) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 70%, rgba(255, 255, 255, 0.2) 0 2px, transparent 3px),
    radial-gradient(circle at 85% 82%, rgba(255, 255, 255, 0.24) 0 2px, transparent 3px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 28%, rgba(35, 76, 65, 0.05) 72%, transparent 100%);
  background-size: 160px 160px, 220px 220px, 180px 180px, 260px 260px, 100% 100%;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(30, 22, 11, 0.38);
  backdrop-filter: blur(12px);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  position: relative;
  overflow: hidden;
  width: min(480px, 100%);
  padding: 32px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 252, 244, 0.96), rgba(255, 246, 228, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -1px auto auto -1px;
  width: 170px;
  height: 170px;
  background: radial-gradient(circle, rgba(217, 162, 75, 0.26), transparent 70%);
  pointer-events: none;
}

.auth-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 600;
}

.auth-hint {
  margin: 14px 0 0;
  color: var(--muted);
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 18px 72px;
}

.shell::before {
  content: "";
  position: absolute;
  inset: 72px 18px auto;
  height: 320px;
  border-radius: calc(var(--radius) + 18px);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 100%);
  pointer-events: none;
  opacity: 0.7;
}

.app-topbar,
.hero,
.card,
.tabs {
  backdrop-filter: blur(14px);
}

.app-topbar {
  position: sticky;
  top: 10px;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 252, 244, 0.84), rgba(249, 240, 220, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow: 0 16px 42px rgba(62, 40, 7, 0.12);
}

.app-topbar-main,
.app-topbar-side {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-topbar-main {
  flex: 1 1 360px;
}

.app-topbar-side {
  flex: 1 1 520px;
  justify-content: flex-end;
}

.app-user {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.app-user strong {
  font-size: 1.08rem;
  letter-spacing: 0.01em;
}

.app-user .muted {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 14px;
  background: rgba(35, 76, 65, 0.08);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
}

.header-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill-lite {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(87, 55, 12, 0.1);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-pill-lite.is-live {
  color: var(--accent);
  background: rgba(35, 76, 65, 0.08);
}

.status-pill-lite.is-live::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(35, 76, 65, 0.12);
}

.toolbar-select {
  display: grid;
  gap: 6px;
  flex: 1 1 280px;
  min-width: 240px;
}

.toolbar-select span {
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.toolbar-select select {
  width: 100%;
  min-width: 0;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.app-topbar-actions,
.hero-actions,
.form-actions,
.table-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.app-topbar-actions {
  margin-left: auto;
  padding: 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(87, 55, 12, 0.08);
}

#refresh-all {
  color: #173227;
  background: linear-gradient(135deg, #f3ca6a, #d9982d);
  box-shadow: 0 14px 24px rgba(176, 116, 23, 0.22);
}

#refresh-all:hover {
  filter: saturate(1.08);
}

#download-backup {
  color: #183c34;
  background: linear-gradient(135deg, #dfece7, #c5ddd5);
  box-shadow: 0 14px 24px rgba(35, 76, 65, 0.16);
}

#logout-button {
  color: #8f351c;
  background: linear-gradient(135deg, #f7e4dd, #efc8bb);
  box-shadow: 0 14px 24px rgba(141, 52, 23, 0.14);
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  padding: 24px 26px 26px;
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(217, 162, 75, 0.24), transparent 26%),
    linear-gradient(145deg, rgba(255, 252, 244, 0.94), rgba(246, 233, 196, 0.84));
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.hero::before {
  top: -78px;
  right: -30px;
  width: 230px;
  height: 230px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.54), transparent 72%);
}

.hero::after {
  bottom: -84px;
  left: 34%;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(35, 76, 65, 0.12), transparent 70%);
}

.hero-main,
.hero-side,
.hero-stats {
  display: grid;
  gap: 12px;
}

.hero-main {
  align-content: start;
  gap: 14px;
}

.hero-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
}

.hero-runtime {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 280px;
}

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

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4.2rem);
  line-height: 0.95;
}

.hero h1 {
  max-width: 520px;
  font-size: clamp(1.9rem, 2.4vw, 2.7rem);
  line-height: 1.04;
}

h2 {
  font-size: 1.7rem;
}

h3 {
  font-size: 1.08rem;
}

.hero-copy,
.section-head p,
.stat-label,
label span,
th,
td,
li,
button,
input,
select,
textarea,
.muted {
  font-size: 1.02rem;
}

.hero-copy,
.section-head p,
.stat-label,
.muted {
  color: var(--muted);
}

.hero-copy,
.section-head p,
.muted {
  font-weight: 500;
  line-height: 1.6;
}

.hero-copy {
  max-width: 680px;
}

label span {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hero-insight {
  display: grid;
  gap: 14px;
}

.trend-chart-card {
  position: relative;
  overflow: hidden;
  padding: 16px 18px 12px;
  border-radius: 18px;
  border: 1px solid rgba(87, 55, 12, 0.12);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.86), rgba(244, 234, 208, 0.94));
  box-shadow: var(--shadow-soft);
}

.trend-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 14px;
}

.trend-chart-head h3 {
  margin-top: 4px;
  font-size: 1.18rem;
}

.trend-kicker {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(35, 76, 65, 0.1);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.trend-chart-summary {
  display: grid;
  gap: 4px;
  text-align: right;
}

.trend-chart-summary strong {
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
}

.trend-chart-summary span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.trend-chart-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.trend-chart-empty {
  padding: 28px 10px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}

.trend-chart-guide {
  stroke: rgba(87, 55, 12, 0.11);
  stroke-dasharray: 5 7;
}

.trend-chart-area {
  fill: url(#trend-fill);
}

.trend-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.trend-chart-point circle {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2;
}

.trend-chart-point text,
.trend-chart-value text {
  fill: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
}

.trend-chart-point.is-active circle {
  fill: var(--accent-highlight);
}

.trend-chart-value text {
  fill: var(--accent);
}

.hero-notice-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hero-growth-card,
.hero-alert {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(87, 55, 12, 0.12);
  box-shadow: var(--shadow-soft);
}

.hero-growth-card {
  padding: 18px 20px 20px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.82), rgba(244, 234, 208, 0.92));
}

.hero-growth-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}

.hero-growth-head h3 {
  margin-top: 4px;
  font-size: 1.3rem;
}

.hero-growth-head strong {
  font-size: 1.5rem;
  color: var(--accent);
  line-height: 1;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(35, 76, 65, 0.1);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.growth-track {
  display: grid;
  gap: 8px;
}

.growth-track-meta {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.growth-track-meta strong {
  color: var(--text);
  font-size: 0.95rem;
}

.growth-track-bar {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: rgba(91, 60, 16, 0.1);
}

.growth-track-bar span {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #3a6d60, #1f4339);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.growth-track.is-earth .growth-track-bar span {
  background: linear-gradient(90deg, #d59b47, #9e5f2b);
}

.growth-track.is-highlight .growth-track-bar span {
  background: linear-gradient(90deg, #efd37f, #d79b2b);
}

.growth-track.is-neutral .growth-track-bar span {
  background: linear-gradient(90deg, #8aa69d, #49685f);
}

.hero-alert {
  min-width: 0;
  padding: 14px 15px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
}

.hero-alert strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 1rem;
}

.hero-alert p {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.hero-alert.is-accent {
  background: linear-gradient(145deg, rgba(226, 238, 233, 0.98), rgba(206, 226, 218, 0.9));
}

.hero-alert.is-warning {
  background: linear-gradient(145deg, rgba(255, 239, 212, 0.98), rgba(246, 218, 172, 0.92));
}

.hero-alert.is-earth {
  background: linear-gradient(145deg, rgba(253, 234, 213, 0.98), rgba(241, 208, 180, 0.92));
}

.metric-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(87, 55, 12, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(244, 236, 218, 0.95));
  box-shadow: var(--shadow-soft);
}

.metric-card.is-primary {
  min-height: 156px;
  padding: 18px;
  color: #fff8ec;
  background:
    linear-gradient(160deg, rgba(36, 78, 66, 0.96), rgba(21, 56, 47, 0.98));
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 22px 38px rgba(23, 57, 48, 0.26);
}

.metric-card.is-danger {
  background:
    linear-gradient(180deg, rgba(255, 248, 244, 0.96), rgba(251, 236, 228, 0.98));
}

.metric-card.is-wheat {
  background:
    linear-gradient(180deg, rgba(255, 249, 235, 0.96), rgba(248, 230, 180, 0.98));
}

.metric-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.metric-card.is-primary .metric-label {
  color: rgba(255, 248, 236, 0.78);
}

.metric-value {
  display: inline-flex;
  align-items: end;
  gap: 7px;
  color: var(--text);
  min-width: 0;
}

.metric-card.is-primary .metric-value {
  color: #fff8ec;
}

.metric-number {
  font-size: clamp(1.5rem, 2vw, 2.35rem);
  line-height: 0.98;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.metric-unit {
  margin-bottom: 4px;
  color: rgba(37, 27, 16, 0.56);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card.is-primary .metric-unit {
  color: rgba(255, 248, 236, 0.58);
}

.metric-value.is-danger,
.metric-meta.is-down {
  color: var(--danger);
}

.metric-value.is-wheat,
.metric-meta.is-warning {
  color: var(--warning);
}

.metric-meta {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

.metric-card.is-primary .metric-meta {
  color: rgba(255, 248, 236, 0.72);
}

.metric-meta.is-up {
  color: var(--accent);
}

.metric-meta.is-neutral {
  color: var(--muted);
}

.metric-card.is-primary .metric-meta.is-up {
  color: #b8e2d6;
}

.metric-card.is-primary .metric-meta.is-down {
  color: #f4c7bb;
}

.metric-card.is-primary .metric-meta.is-warning {
  color: #f4de9d;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 22px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 248, 232, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.44),
    0 10px 26px rgba(62, 40, 7, 0.08);
}

.tab-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 11px 15px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.tab-button:hover {
  background: rgba(35, 76, 65, 0.08);
  color: var(--accent);
  transform: translateY(-1px);
}

.tab-button.is-active {
  background: linear-gradient(135deg, #305b4f, #1f463a);
  color: #fff8ec;
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(31, 70, 58, 0.22);
}

.tab-button[hidden],
.tab-panel[hidden],
[data-hidden="true"] {
  display: none !important;
}

.tab-panel {
  display: none;
  animation: rise 280ms ease;
}

.tab-panel.is-active {
  display: block;
}

.grid {
  display: grid;
  gap: 18px;
}

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

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

.card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--surface-strong), var(--surface));
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.64);
  box-shadow: 0 22px 44px rgba(62, 40, 7, 0.12);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  position: relative;
  padding-bottom: 8px;
}

.section-head h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 64px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), rgba(217, 162, 75, 0.9));
}

.stack-form,
.line-items,
.split-tables {
  display: grid;
  gap: 14px;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(117, 98, 68, 0.82);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(35, 76, 65, 0.48);
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 4px rgba(35, 76, 65, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(35, 76, 65, 0.12);
}

.primary-button,
.ghost-button,
.remove-button,
.table-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 16px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.button-icon,
.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.button-icon svg,
.tab-icon svg {
  width: 16px;
  height: 16px;
}

.button-label {
  white-space: nowrap;
}

.primary-button {
  color: #f5f0e2;
  background: linear-gradient(135deg, #3e6b5d, #21453a);
  box-shadow: 0 12px 22px rgba(33, 69, 58, 0.24);
}

.ghost-button,
.table-button {
  color: var(--accent);
  background: linear-gradient(180deg, #edf4f1, #dbe9e4);
  box-shadow: 0 8px 16px rgba(35, 76, 65, 0.12);
}

.remove-button,
.table-button.danger {
  color: #fff2e8;
  background: linear-gradient(135deg, #a44a25, #87391b);
  box-shadow: 0 10px 18px rgba(142, 64, 32, 0.22);
}

.table-button {
  padding: 8px 12px;
}

.primary-button:hover,
.ghost-button:hover,
.remove-button:hover,
.table-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.03);
}

.line-items-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.line-row,
.purchase-return-line,
.return-line,
.stocktake-line {
  display: grid;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(247, 239, 220, 0.78));
  border: 1px solid rgba(87, 55, 12, 0.09);
}

.line-row {
  grid-template-columns: 1.4fr 0.9fr 0.9fr auto;
}

.line-row.is-sale-row {
  grid-template-columns: minmax(0, 1.35fr) minmax(110px, 0.78fr) minmax(130px, 0.84fr) minmax(140px, 0.92fr) auto;
}

.line-total-box {
  min-width: 0;
}

.line-total-box output {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(35, 76, 65, 0.14);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, rgba(235, 244, 239, 0.94), rgba(222, 234, 228, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 8px 18px rgba(35, 76, 65, 0.08);
  white-space: nowrap;
}

.line-promo {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--accent);
  background: rgba(47, 93, 80, 0.08);
  border: 1px dashed rgba(47, 93, 80, 0.22);
}

.line-promo.is-warning {
  color: var(--warning);
  background: rgba(163, 107, 28, 0.1);
  border-color: rgba(163, 107, 28, 0.34);
}

.return-line {
  grid-template-columns: 1.3fr 0.9fr 1fr 1fr;
}

.purchase-return-line {
  grid-template-columns: 1.4fr 0.9fr 1fr;
}

.inline-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(47, 93, 80, 0.12);
}

.stocktake-line {
  grid-template-columns: 1.2fr 0.8fr 0.8fr auto;
}

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

.table-toolbar input[type="search"] {
  max-width: 360px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(250, 243, 226, 0.88));
}

.table-wrap {
  border-radius: 20px;
  border: 1px solid rgba(87, 55, 12, 0.08);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid rgba(87, 55, 12, 0.1);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-weight: 600;
  background: rgba(248, 241, 224, 0.94);
  backdrop-filter: blur(12px);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.52);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.18);
}

tbody tr.is-low-stock {
  background: rgba(163, 107, 28, 0.08);
}

.stat-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 19px;
  border-radius: 22px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.88), rgba(241, 231, 205, 0.94));
  border: 1px solid rgba(87, 55, 12, 0.08);
  box-shadow: var(--shadow-soft);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-highlight));
}

.stat-value {
  margin-top: 8px;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.feature-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.42);
}

.status-pill.is-paid,
.status-pill.is-active {
  background: rgba(47, 93, 80, 0.12);
  color: var(--accent);
}

.status-pill.is-open,
.status-pill.is-inactive {
  background: rgba(142, 64, 32, 0.12);
  color: var(--danger);
}

.status-pill.is-warning {
  background: rgba(163, 107, 28, 0.14);
  color: var(--warning);
}

.form-note {
  padding: 13px 15px;
  border-radius: 18px;
  border: 1px solid rgba(35, 76, 65, 0.12);
  background:
    linear-gradient(180deg, rgba(47, 93, 80, 0.09), rgba(47, 93, 80, 0.05));
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.toast {
  position: sticky;
  top: 12px;
  z-index: 20;
  margin-bottom: 12px;
  padding: 14px 16px;
  border-radius: 20px;
  color: #fdf9ed;
  background: linear-gradient(135deg, rgba(36, 78, 66, 0.96), rgba(24, 57, 48, 0.96));
  box-shadow: 0 18px 32px rgba(24, 52, 45, 0.2);
}

.toast.is-error {
  background: rgba(124, 49, 23, 0.94);
}

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

.amount-in {
  color: var(--accent);
  font-weight: 700;
}

.amount-out {
  color: var(--danger);
  font-weight: 700;
}

.audit-summary {
  font-weight: 600;
}

.audit-detail {
  max-width: 420px;
}

.audit-detail summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.audit-payloads {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.audit-payload {
  display: grid;
  gap: 6px;
}

.audit-payload pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(87, 55, 12, 0.1);
  color: var(--text);
  font: 0.82rem/1.45 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.permission-editor {
  display: grid;
  gap: 14px;
}

.permission-group {
  margin: 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(87, 55, 12, 0.1);
  background: rgba(255, 255, 255, 0.58);
}

.permission-group legend {
  padding: 0 8px;
  color: var(--accent);
  font-weight: 700;
}

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

.permission-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(87, 55, 12, 0.06);
}

.permission-option input {
  width: auto;
  margin: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1160px) {
  .hero,
  .two-columns,
  .three-columns,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .app-topbar,
  .app-topbar-main,
  .app-topbar-side,
  .hero-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .hero-runtime,
  .hero-notice-strip,
  .overview-metric-grid {
    grid-template-columns: 1fr;
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 14px 12px 40px;
  }

  .auth-card,
  .hero,
  .card,
  .app-topbar {
    padding: 18px;
  }

  .tabs {
    border-radius: 18px;
  }

  .hero-stats,
  .overview-metric-grid,
  .hero-notice-strip {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .line-row,
  .purchase-return-line,
  .return-line,
  .stocktake-line,
  .permission-grid,
  .app-topbar,
  .table-toolbar,
  .app-topbar-actions,
  .app-topbar-main,
  .app-topbar-side,
  .hero-actions,
  .form-actions,
  .table-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .table-toolbar input[type="search"] {
    max-width: none;
  }

  .toolbar-select {
    min-width: 0;
  }

  .hero-runtime {
    max-width: none;
    justify-content: flex-start;
  }

  .app-topbar {
    position: static;
  }
}
