/* ==========================================================================
   DairyPro ERP – design system v2 (light, compact, calm)
   tokens → base → shell → components → modules → utilities → responsive
   ========================================================================== */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20B9, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --brand: #0f7b63;
  --brand-600: #0b6551;
  --brand-700: #094f40;
  --brand-50: #ecf8f4;
  --brand-100: #d2efe5;
  --brand-200: #a6dfcb;
  --accent: #f59e0b;
  --accent-50: #fff7e6;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e4e7ec;
  --line-2: #f0f2f5;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --hover: #f5f6f8;
  --success: #079455;
  --success-50: #ecfdf3;
  --danger: #d92d20;
  --danger-50: #fef3f2;
  --warning: #b54708;
  --warning-50: #fffaeb;
  --info: #175cd3;
  --info-50: #eff8ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 40px -8px rgba(16, 24, 40, 0.18), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
  --ring: 0 0 0 4px rgba(15, 123, 99, 0.14);
  --sidebar-w: 248px;
  --rail-w: 68px;
  --topbar-h: 56px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Devanagari', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  color: var(--brand-600);
}
h1,
h2,
h3,
h4 {
  margin: 0 0 0.4rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--ink);
}
h1 {
  font-size: 1.375rem;
}
h2 {
  font-size: 1rem;
}
h3 {
  font-size: 0.9375rem;
}
p {
  margin: 0 0 0.75rem;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.25rem 0;
}
::selection {
  background: var(--brand-100);
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.icon-sm {
  width: 16px;
  height: 16px;
}
.icon-xs {
  width: 14px;
  height: 14px;
}
.icon-lg {
  width: 22px;
  height: 22px;
}
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus {
  left: 8px;
}

/* ============================ Shell ============================ */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition:
    width 0.2s var(--ease),
    transform 0.2s var(--ease);
}
.sb-head {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 16px;
}
.sidebar-brand,
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
}
.sb-brand:hover {
  color: var(--ink);
}
.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(140deg, #19a37f 0%, #0f7b63 55%, #0a5c4a 100%);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 2px 6px rgba(15, 123, 99, 0.35);
}
.brand-mark .icon {
  width: 17px;
  height: 17px;
}
.sb-collapse {
  margin-left: auto;
}
.sb-dairy {
  margin: 4px 12px 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  background: linear-gradient(180deg, #fff, #fafbfc);
  min-width: 0;
}
.sb-dairy:hover {
  border-color: var(--brand-200);
  color: var(--ink);
}
.sb-dairy .avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 12px;
}
.sb-dairy-text {
  min-width: 0;
  line-height: 1.25;
}
.sb-dairy-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-dairy-text span {
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
}
.sidebar-nav,
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
  scrollbar-width: thin;
}
.nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  padding: 14px 10px 6px;
  white-space: nowrap;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 2px;
  white-space: nowrap;
  position: relative;
  transition:
    background 0.12s,
    color 0.12s;
}
.nav-link .icon {
  color: var(--faint);
  transition: color 0.12s;
}
.nav-link:hover {
  background: var(--hover);
  color: var(--ink);
}
.nav-link:hover .icon {
  color: var(--ink-2);
}
.nav-link.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.nav-link.active .icon {
  color: var(--brand);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.nav-link .badge {
  margin-left: auto;
}
.sb-foot,
.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--line-2);
}
.plan-card {
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(135deg, var(--brand-50), #f4fbf8);
  border: 1px solid var(--brand-100);
  font-size: 12.5px;
}
.plan-card strong {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.plan-card .meter {
  height: 6px;
  background: #fff;
  margin: 6px 0 8px;
}
.plan-card a {
  font-weight: 600;
}
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s var(--ease);
}
.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .menu-toggle {
  display: none;
}
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 100%);
  height: 36px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--faint);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition:
    border-color 0.12s,
    background 0.12s;
}
.search-trigger:hover {
  border-color: #d0d5dd;
  background: #fff;
}
.search-trigger span {
  flex: 1;
  text-align: left;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}
.dot {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.menu-wrap,
.user-menu {
  position: relative;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.user-chip:hover {
  background: var(--hover);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-100), #e6f4ff);
  color: var(--brand-700);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}
.user-chip .who {
  text-align: left;
  line-height: 1.2;
  font-size: 13px;
  font-weight: 600;
}
.user-chip .who small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}
.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 232px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 50;
}
.dropdown.open {
  display: block;
  animation: pop 0.14s var(--ease);
}
.dropdown-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 4px;
}
.dropdown-head strong {
  display: block;
  font-size: 13.5px;
}
.dropdown-head span {
  font-size: 12px;
  color: var(--muted);
}
.dropdown a,
.dropdown button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  background: none;
  border: 0;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}
.dropdown a .icon,
.dropdown button .icon {
  color: var(--faint);
}
.dropdown a:hover,
.dropdown button:hover {
  background: var(--hover);
  color: var(--ink);
}
.dropdown .dd-sep {
  height: 1px;
  background: var(--line-2);
  margin: 4px 0;
}
.dropdown .dd-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--faint);
}
.content {
  padding: 20px 28px 40px;
  width: 100%;
  max-width: 1480px;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.crumbs a {
  color: var(--muted);
}
.crumbs a:hover {
  color: var(--ink);
}
.crumbs .sep {
  color: var(--faint);
}
.crumbs .current {
  color: var(--ink-2);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
}
.page-head p {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 13.5px;
  max-width: 760px;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.backdrop {
  display: none;
}

/* Collapsed sidebar (icon rail) */
.shell.collapsed .sidebar {
  width: var(--rail-w);
}
.shell.collapsed .main {
  margin-left: var(--rail-w);
}
.shell.collapsed .sb-brand-text,
.shell.collapsed .sb-dairy-text,
.shell.collapsed .nav-section,
.shell.collapsed .nav-label,
.shell.collapsed .plan-card .plan-body {
  display: none;
}
.shell.collapsed .sb-head {
  flex-direction: column;
  height: auto;
  padding: 12px 0 6px;
  gap: 6px;
}
.shell.collapsed .sb-collapse {
  margin: 0;
}
.shell.collapsed .sb-collapse .icon {
  transform: rotate(180deg);
}
.shell.collapsed .sb-dairy {
  justify-content: center;
  padding: 6px;
  margin: 4px 10px 8px;
}
.shell.collapsed .nav-link {
  justify-content: center;
  padding: 0;
}
.shell.collapsed .nav-link.active::before {
  left: -10px;
}
.shell.collapsed .sb-nav {
  padding-top: 8px;
}
.shell.collapsed .nav-group + .nav-group {
  border-top: 1px solid var(--line-2);
  padding-top: 6px;
  margin-top: 6px;
}
.shell.collapsed .plan-card {
  padding: 8px;
  text-align: center;
}

/* ============================ Components ============================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  min-height: 54px;
}
.card-head h2,
.card-head h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}
.card-head .sub {
  color: var(--muted);
  font-size: 12.5px;
  display: block;
  margin-top: 1px;
}
.card-body {
  padding: 18px;
}
.card-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line-2);
  background: #fcfcfd;
  border-radius: 0 0 var(--radius) var(--radius);
}
.grid {
  display: grid;
  gap: 16px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid-main-side {
  grid-template-columns: minmax(0, 1fr) 340px;
}
.grid-wide-side {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}
.span-2 {
  grid-column: span 2;
}
.stack > * + * {
  margin-top: 16px;
}

/* KPI cards (compact) */
.kpi {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.kpi-label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kpi-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--brand-50);
  color: var(--brand);
  flex: none;
}
.kpi-icon .icon {
  width: 15px;
  height: 15px;
}
.kpi-icon.amber {
  background: var(--accent-50);
  color: #b45309;
}
.kpi-icon.blue {
  background: var(--info-50);
  color: var(--info);
}
.kpi-icon.red {
  background: var(--danger-50);
  color: var(--danger);
}
.kpi-value {
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value small {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}
.kpi-foot {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.kpi .spark {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 92px;
  height: 34px;
  opacity: 0.95;
}
.trend-up,
.trend-down,
.trend-flat {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 999px;
}
.trend-up {
  color: var(--success);
  background: var(--success-50);
}
.trend-down {
  color: var(--danger);
  background: var(--danger-50);
}
.trend-flat {
  color: var(--muted);
  background: var(--line-2);
}

/* Stat strip: several KPIs in one card */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
}
.stat-strip > div {
  padding: 12px 18px;
  border-right: 1px solid var(--line-2);
  min-width: 0;
}
.stat-strip > div:last-child {
  border-right: 0;
}
.stat-strip .lbl {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.stat-strip .val {
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.stat-strip .val small {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}
.stat-strip .hint {
  font-size: 11.5px;
  color: var(--faint);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid #d0d5dd;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition:
    background 0.12s,
    border-color 0.12s,
    box-shadow 0.12s,
    transform 0.06s;
}
.btn:hover {
  background: var(--hover);
  color: var(--ink);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn[disabled],
.btn.is-loading {
  opacity: 0.6;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn .icon {
  width: 16px;
  height: 16px;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow:
    0 1px 2px rgba(16, 24, 40, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #3b2600;
}
.btn-accent:hover {
  background: #e08e06;
  color: #3b2600;
}
.btn-danger {
  color: var(--danger);
  border-color: #fecdca;
}
.btn-danger:hover {
  background: var(--danger-50);
  color: var(--danger);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--hover);
}
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 8px;
}
.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
  border-radius: 10px;
}
.btn-block {
  width: 100%;
}
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.link-btn.danger {
  color: var(--danger);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  background: var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-green {
  background: var(--success-50);
  color: var(--success);
  border-color: #abefc6;
}
.badge-red {
  background: var(--danger-50);
  color: var(--danger);
  border-color: #fecdca;
}
.badge-amber {
  background: var(--warning-50);
  color: var(--warning);
  border-color: #fedf89;
}
.badge-blue {
  background: var(--info-50);
  color: var(--info);
  border-color: #b2ddff;
}
.badge-brand {
  background: var(--brand-50);
  color: var(--brand-700);
  border-color: var(--brand-100);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field.full {
  grid-column: 1 / -1;
}
.field label,
.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.field .req {
  color: var(--danger);
}
.field .hint {
  font-size: 12px;
  color: var(--muted);
}
.field .error {
  font-size: 12px;
  color: var(--danger);
  font-weight: 500;
}
.input,
select.input,
textarea.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}
select.input {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
textarea.input {
  height: auto;
  min-height: 90px;
  padding: 10px 12px;
  resize: vertical;
}
.input::placeholder {
  color: var(--faint);
}
.input:hover {
  border-color: #b9c0cb;
}
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.input.has-error,
.field.invalid .input {
  border-color: #fda29b;
  box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.08);
}
.input[readonly] {
  background: var(--bg);
}
.input-icon {
  position: relative;
}
.input-icon .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
.input-icon .input {
  padding-left: 36px;
}
.input-group {
  display: flex;
}
.input-group .input {
  border-radius: 9px 0 0 9px;
}
.input-group .addon {
  display: grid;
  place-items: center;
  padding: 0 11px;
  border: 1px solid #d0d5dd;
  border-left: 0;
  border-radius: 0 9px 9px 0;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
  font-size: 13.5px;
}
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 2px;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented label,
.segmented a,
.segmented button {
  padding: 5px 12px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  border: 0;
  background: none;
  font-family: inherit;
  white-space: nowrap;
  transition:
    background 0.12s,
    color 0.12s;
}
.segmented label:hover,
.segmented a:hover,
.segmented button:hover {
  color: var(--ink);
}
.segmented input:checked + label,
.segmented a.active,
.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.segmented input:focus-visible + label {
  outline: 2px solid var(--brand);
}
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
legend {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 10px;
  padding: 0;
}

/* Filter toolbar */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
  background: #fcfcfd;
  border-radius: var(--radius) var(--radius) 0 0;
}
.filters .field {
  min-width: 130px;
  gap: 3px;
}
.filters .field label,
.filters .label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}
.filters .field.grow {
  flex: 1;
  min-width: 200px;
}
.filters .input {
  height: 34px;
  font-size: 13.5px;
}
.filters .btn {
  height: 34px;
}
.quick-ranges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table th a {
  color: inherit;
}
.table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  color: var(--ink-2);
}
.table tbody tr {
  transition: background 0.1s;
}
.table tbody tr:hover {
  background: #f9fafb;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tr[data-href] {
  cursor: pointer;
}
.table .num,
.table th.num {
  text-align: right;
  white-space: nowrap;
}
.table tfoot td {
  font-weight: 650;
  color: var(--ink);
  background: #fafbfc;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.table .muted-row td {
  color: var(--faint);
  text-decoration: line-through;
}
.table-compact td,
.table-compact th {
  padding: 7px 12px;
}
.table td a:not(.btn) {
  font-weight: 500;
}
.row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  opacity: 0.55;
  transition: opacity 0.12s;
}
tr:hover .row-actions {
  opacity: 1;
}
.code-pill {
  display: inline-block;
  min-width: 30px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 650;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.amount-pos {
  color: var(--success);
}
.amount-neg {
  color: var(--danger);
}
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.person .avatar {
  width: 30px;
  height: 30px;
  font-size: 11px;
}
.person .meta {
  min-width: 0;
  line-height: 1.3;
}
.person .meta small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 12.5px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line-2);
}
.pager .pages {
  display: flex;
  gap: 4px;
}
.pager a,
.pager span.cur {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: #fff;
  font-weight: 500;
}
.pager span.cur {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-700);
  font-weight: 650;
}
.pager a:hover {
  background: var(--hover);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}
.empty .empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--brand);
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 8px #f5fbf8;
}
.empty h3 {
  color: var(--ink);
  font-size: 15px;
  margin-top: 6px;
}
.empty p {
  max-width: 360px;
  margin: 0 auto 14px;
  font-size: 13.5px;
}

/* Alerts */
.alert {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid;
  margin-bottom: 16px;
  font-size: 13.5px;
}
.alert .icon {
  flex: none;
}
.alert-warning {
  background: var(--warning-50);
  border-color: #fedf89;
  color: #93370d;
}
.alert-danger {
  background: var(--danger-50);
  border-color: #fecdca;
  color: #912018;
}
.alert-info {
  background: var(--info-50);
  border-color: #b2ddff;
  color: #194185;
}
.alert-success {
  background: var(--success-50);
  border-color: #abefc6;
  color: #085d3a;
}
.alert .btn {
  margin-left: auto;
}

/* Toasts */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(400px, calc(100vw - 40px));
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px 12px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: slidein 0.22s var(--ease);
  font-size: 13.5px;
}
.toast::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex: none;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-50);
}
.toast.error::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-50);
}
.toast.warning::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-50);
}
.toast.info::before {
  background: var(--info);
  box-shadow: 0 0 0 4px var(--info-50);
}
.toast .msg {
  flex: 1;
  color: var(--ink-2);
}
.toast button {
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
}
.toast.hide {
  opacity: 0;
  transform: translateY(8px);
  transition: 0.25s;
}

/* Dialog */
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
  color: var(--ink);
}
dialog::backdrop {
  background: rgba(16, 24, 40, 0.4);
  backdrop-filter: blur(2px);
}
dialog[open] {
  animation: pop 0.16s var(--ease);
}
.dialog-head {
  padding: 18px 20px 4px;
}
.dialog-body {
  padding: 8px 20px 18px;
  color: var(--ink-2);
}
.dialog-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fcfcfd;
  border-radius: 0 0 16px 16px;
}

/* Command palette */
.cmdk {
  width: min(600px, calc(100vw - 32px));
  margin-top: 10vh;
  border-radius: 14px;
}
.cmdk-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.cmdk-input .icon {
  color: var(--faint);
}
.cmdk-input input {
  flex: 1;
  height: 52px;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 15px;
  background: transparent;
  color: var(--ink);
}
.cmdk-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.cmdk-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 600;
  padding: 10px 10px 4px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13.5px;
}
.cmdk-item .icon {
  color: var(--faint);
}
.cmdk-item small {
  margin-left: auto;
  color: var(--faint);
  font-size: 12px;
}
.cmdk-item.sel {
  background: var(--brand-50);
  color: var(--brand-700);
}
.cmdk-item.sel .icon {
  color: var(--brand);
}
.cmdk-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.cmdk-foot {
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--line-2);
  font-size: 11.5px;
  color: var(--muted);
  background: #fcfcfd;
  border-radius: 0 0 14px 14px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tabs a,
.tabs button {
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  border: 0;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  cursor: pointer;
}
.tabs a.active,
.tabs button.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand);
}
.tabs a:hover,
.tabs button:hover {
  color: var(--ink);
}

/* Definition list */
.dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 9px 12px;
  margin: 0;
  font-size: 13.5px;
}
.dl dt {
  color: var(--muted);
}
.dl dd {
  margin: 0;
  font-weight: 500;
  word-break: break-word;
  color: var(--ink);
}

/* Meters */
.meter {
  height: 6px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.6s var(--ease);
}
.meter.warn > span {
  background: var(--accent);
}
.meter.full > span {
  background: var(--danger);
}
.split-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  gap: 2px;
  background: var(--line-2);
}
.split-bar > span {
  display: block;
  height: 100%;
}
.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--muted);
}
.legend-row i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Rank list (top suppliers etc.) */
.rank-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.rank-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 9px 18px;
}
.rank-list li:hover {
  background: #fafbfc;
}
.rank-list .name {
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-list .val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
}
.rank-list .meter {
  grid-column: 1 / -1;
  height: 5px;
}
.rank-list .sub {
  font-size: 12px;
  color: var(--muted);
}

/* Checklist */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.checklist li {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}
.checklist li:last-child {
  border-bottom: 0;
}
.checklist .tick {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px dashed var(--line);
  display: grid;
  place-items: center;
  flex: none;
}
.checklist li.done .tick {
  background: var(--success);
  border: 0;
  color: #fff;
}
.checklist li.done .title {
  color: var(--muted);
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.qa {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13px;
  background: #fff;
  transition:
    border-color 0.12s,
    box-shadow 0.12s,
    transform 0.12s;
}
.qa:hover {
  border-color: var(--brand-200);
  box-shadow: var(--shadow);
  color: var(--ink);
  transform: translateY(-1px);
}
.qa .kpi-icon {
  width: 30px;
  height: 30px;
}

/* Charts */
.chart-box {
  position: relative;
  height: 280px;
}
.chart-box.sm {
  height: 210px;
}
.chart-box.lg {
  height: 320px;
}
.chart-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 18px 0;
}
.chart-legend .item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chart-legend .item span {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-legend .item i {
  width: 10px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}
.chart-legend .item b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

/* Summary strip (statement totals) */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.summary-strip > div {
  padding: 14px;
  text-align: center;
  border-right: 1px solid var(--line-2);
}
.summary-strip > div:last-child {
  border-right: 0;
  background: var(--brand-50);
}
.summary-strip .lbl {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.summary-strip .val {
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.summary-strip .op {
  font-size: 11px;
  color: var(--faint);
}

/* ============================ Milk entry ============================ */
.entry-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}
.entry-card .card-body {
  padding: 20px;
}
.entry-grid {
  display: grid;
  grid-template-columns: 120px 1fr 1fr 1fr;
  gap: 12px;
}
.entry-grid .input {
  height: 54px;
  font-size: 1.4rem;
  font-weight: 650;
  text-align: center;
  font-variant-numeric: tabular-nums;
  border-radius: 12px;
}
.entry-grid label {
  text-align: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.customer-banner {
  margin-top: 14px;
  min-height: 56px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--muted);
  transition:
    background 0.15s,
    border-color 0.15s;
}
.customer-banner.ok {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  color: var(--ink);
}
.customer-banner.bad {
  background: var(--danger-50);
  border: 1px solid #fecdca;
  color: var(--danger);
}
.customer-banner .name {
  font-weight: 650;
  font-size: 1rem;
}
.calc-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.calc {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
  background: #fff;
}
.calc .lbl {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.calc .val {
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.calc.total {
  background: linear-gradient(135deg, #12957a, #0b6551);
  border: 0;
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(15, 123, 99, 0.6);
}
.calc.total .lbl {
  color: #c9f0e3;
}
.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: #fff;
  color: var(--ink-2);
}
.flash-row {
  animation: flashrow 1.4s ease-out;
}

/* ============================ Auth ============================ */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  background: #fff;
}
.auth-side {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(600px 400px at 0% 0%, rgba(52, 211, 153, 0.35), transparent 60%),
    radial-gradient(500px 400px at 100% 100%, rgba(245, 158, 11, 0.18), transparent 60%),
    linear-gradient(160deg, #06372d, #0b5e4b 60%, #0f7b63);
  color: #d1f0e6;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-side::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 30% 40%, #000, transparent 75%);
  pointer-events: none;
}
.auth-side > * {
  position: relative;
  z-index: 1;
}
.auth-side h2 {
  font-size: 1.9rem;
  color: #fff;
  max-width: 440px;
  letter-spacing: -0.02em;
}
.auth-side ul {
  padding: 0;
  list-style: none;
  margin: 20px 0 0;
}
.auth-side li {
  display: flex;
  gap: 10px;
  margin: 12px 0;
  align-items: center;
}
.auth-side li .icon {
  width: 22px;
  height: 22px;
  padding: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #6ee7b7;
}
.auth-quote {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 16px;
  max-width: 440px;
  font-size: 13.5px;
}
.auth-main {
  display: grid;
  place-items: center;
  padding: 40px 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}
.auth-card.wide {
  max-width: 640px;
}
.auth-card h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}
.auth-logo {
  display: none;
}

/* ============================ Print ============================ */
@media print {
  .sidebar,
  .topbar,
  .page-actions,
  .filters,
  .no-print,
  .toasts,
  .crumbs {
    display: none !important;
  }
  .main {
    margin: 0 !important;
  }
  .content {
    padding: 0;
  }
  .card {
    border: 0;
    box-shadow: none;
  }
  body {
    background: #fff;
  }
}

/* ============================ Motion ============================ */
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}
@keyframes slidein {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes flashrow {
  from {
    background: #fef7e0;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes fadeup {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.content > * {
  animation: fadeup 0.28s var(--ease) both;
}
@media (prefers-reduced-motion: reduce) {
  *,
  .content > * {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================ Utilities ============================ */
.muted {
  color: var(--muted);
}
.faint {
  color: var(--faint);
}
.small {
  font-size: 12.5px;
}
.right {
  text-align: right;
}
.center {
  text-align: center;
}
.nowrap {
  white-space: nowrap;
}
.bold {
  font-weight: 650;
}
.mono {
  font-family: var(--mono);
}
.flex {
  display: flex;
  gap: 8px;
  align-items: center;
}
.flex-wrap {
  flex-wrap: wrap;
}
.between {
  justify-content: space-between;
}
.mt-0 {
  margin-top: 0;
}
.mt-1 {
  margin-top: 8px;
}
.mt-2 {
  margin-top: 16px;
}
.mt-3 {
  margin-top: 24px;
}
.mb-0 {
  margin-bottom: 0;
}
.mb-2 {
  margin-bottom: 16px;
}
.p-0 {
  padding: 0 !important;
}
.hidden {
  display: none !important;
}
.text-success {
  color: var(--success);
}
.text-danger {
  color: var(--danger);
}
.text-warning {
  color: var(--warning);
}
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================ Responsive ============================ */
@media (max-width: 1280px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .entry-layout,
  .grid-main-side,
  .grid-wide-side {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    box-shadow: none;
  }
  .sidebar.open {
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  .shell.collapsed .sidebar .sb-brand-text,
  .shell.collapsed .sidebar .sb-dairy-text,
  .shell.collapsed .sidebar .nav-section,
  .shell.collapsed .sidebar .nav-label,
  .shell.collapsed .sidebar .plan-body {
    display: revert;
  }
  .sb-collapse {
    display: none;
  }
  .backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.35);
    z-index: 35;
  }
  .main,
  .shell.collapsed .main {
    margin-left: 0;
  }
  .topbar {
    padding: 0 12px;
  }
  .topbar .menu-toggle {
    display: grid;
  }
  .search-trigger kbd,
  .search-trigger span {
    display: none;
  }
  .search-trigger {
    width: 36px;
    padding: 0;
    justify-content: center;
    background: transparent;
    border-color: transparent;
  }
  .content {
    padding: 14px 14px 32px;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: auto;
  }
  .auth-page {
    grid-template-columns: 1fr;
  }
  .auth-side {
    display: none;
  }
  .auth-logo {
    display: flex;
    margin-bottom: 24px;
  }
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-strip > div:nth-child(2n) {
    border-right: 0;
  }
  .stat-strip > div:nth-child(n + 3) {
    border-top: 1px solid var(--line-2);
  }
  .user-chip .who,
  .create-label {
    display: none;
  }
}
@media (max-width: 640px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-4 .kpi-value {
    font-size: 1.1rem;
  }
  .grid-4 .kpi .spark {
    display: none;
  }
  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .entry-grid {
    grid-template-columns: 1fr 1fr;
  }
  .calc-row {
    grid-template-columns: 1fr;
  }
  .dl {
    grid-template-columns: 1fr;
  }
  .page-head h1 {
    font-size: 1.2rem;
  }
  .page-actions .btn {
    flex: 1;
  }
  .quick-actions {
    grid-template-columns: 1fr;
  }
}

/* Plan card in sidebar: full card expanded, icon only on the rail */
.plan-card .plan-icon {
  display: none;
}
.shell.collapsed .plan-card .plan-icon {
  display: inline-block;
}
@media (max-width: 960px) {
  .shell.collapsed .plan-card .plan-icon {
    display: none;
  }
}

/* Trend card: the visible chart panel stretches to the height of the side column */
.trend-card {
  display: flex;
  flex-direction: column;
}
.trend-card [data-chart-panel]:not([hidden]) {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.trend-card [data-chart-panel] .card-body {
  flex: 1;
  display: flex;
}
.trend-card .chart-box {
  flex: 1;
  height: auto;
  min-height: 280px;
}
.card-head {
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  /* Chart.js sets an inline display style on canvases, so this needs !important */
  .kpi .spark {
    display: none !important;
  }
  .trend-card .chart-box {
    min-height: 240px;
  }
}
