/* ============================================================
   SHUBHA LAXMI DAIRY — Shop Management System Styles
   ============================================================ */

/* === RESET & BASE === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --cream: #F7F7FA;
  --cream-d: #EDEDF3;
  --gold: #E8483F;
  --gold-d: #C7362E;
  --gold-l: #F2958D;
  --brand-l: #FBEAE9;
  --brown: #2B2B33;
  --brown-d: #1C1C22;
  --white: #ffffff;
  --text: #333333;
  --text-light: #777777;
  --success: #28a745;
  --warning: #f0ad4e;
  --danger: #B0272F;
  --info: #4a90d9;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 56px;
  --radius: 16px;
  --shadow: 0 2px 14px rgba(43,43,51,0.06);
  --shadow-lg: 0 10px 34px rgba(43,43,51,0.12);
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-serif: 'Inter', -apple-system, sans-serif;
}

html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
table { border-collapse: collapse; width: 100%; }


/* === LAYOUT === */
.app {
  display: flex;
  min-height: 100vh;
}


/* === SIDEBAR === */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--brown-d);
  color: rgba(255,255,255,0.7);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease, width 0.2s ease;
}

.sidebar__collapse-btn {
  position: absolute;
  top: 1.4rem;
  right: -12px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--white);
  border: 2px solid var(--brown-d);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  transition: transform 0.2s ease;
}
.sidebar__collapse-btn:hover { background: var(--gold-d); }

/* Collapsed (icon-only rail) state — toggled via .sidebar-collapsed on #app */
.app.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.app.sidebar-collapsed .sidebar__collapse-btn svg { transform: rotate(180deg); }
.app.sidebar-collapsed .sidebar__brand small,
.app.sidebar-collapsed .sidebar__logo,
.app.sidebar-collapsed .sidebar__logo-accent,
.app.sidebar-collapsed .sidebar__link-text,
.app.sidebar-collapsed .sidebar__user-name,
.app.sidebar-collapsed .sidebar__user-role,
.app.sidebar-collapsed .sidebar__badge {
  display: none;
}
.app.sidebar-collapsed .sidebar__brand {
  padding: 1.5rem 0.75rem 1rem;
  text-align: center;
}
.app.sidebar-collapsed .sidebar__brand a::before {
  content: 'SLD';
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--white);
  font-size: 1.1rem;
}
.app.sidebar-collapsed .sidebar__link {
  justify-content: center;
  padding: 0.7rem;
  margin: 0.15rem 0.5rem;
}
.app.sidebar-collapsed .sidebar__link--logout { justify-content: center; }
.app.sidebar-collapsed .sidebar__user { justify-content: center; }
.app.sidebar-collapsed .sidebar__footer { padding: 1rem 0.5rem; }

.sidebar__brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__brand a {
  display: block;
  text-decoration: none;
}
.sidebar__logo {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  display: block;
  line-height: 1.2;
}
.sidebar__logo-accent {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
}
.sidebar__brand small {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-top: 0.35rem;
}

.sidebar__nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  margin: 0.15rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  transition: all 0.2s;
  border-radius: 10px;
  width: auto;
}
.sidebar__link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}
.sidebar__link.active {
  color: var(--white);
  background: var(--gold);
  box-shadow: 0 4px 14px rgba(232,72,63,0.35);
}
.sidebar__icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar__divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.5rem 1.25rem;
}

.sidebar__footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.sidebar__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.sidebar__user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--white);
}
.sidebar__user-role {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar__link--logout {
  font-size: 0.8rem;
  padding: 0.5rem 0;
  border-left: none;
  color: rgba(255,255,255,0.4);
}
.sidebar__link--logout:hover {
  color: var(--danger);
  background: none;
}


/* === TOP BAR (mobile) === */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--white);
  box-shadow: var(--shadow);
  z-index: 90;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
}
.topbar__toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.topbar__toggle span {
  display: block;
  width: 20px; height: 2px;
  background: var(--brown);
  border-radius: 2px;
}
.topbar__title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brown);
  flex: 1;
}
.topbar__role {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: rgba(232,72,63,0.1);
  padding: 3px 10px;
  border-radius: 20px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 95;
}


/* === MAIN CONTENT === */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2rem clamp(1.25rem, 3vw, 2.5rem);
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}
.app.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-w-collapsed);
}


/* === PAGE HEADER === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--brown);
}


/* === CARDS === */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.card__header h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brown);
}
.card__header a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  transition: color 0.2s;
}
.card__header a:hover { color: var(--gold-d); }
.card__body {
  padding: 1.5rem;
}


/* === STATS GRID === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card__label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}
.stat-card__value {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brown);
}
.stat-card__sub {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.4rem;
}
.stat-card__icon {
  position: absolute;
  top: 1rem; right: 1rem;
  font-size: 1.5rem;
  opacity: 0.3;
}

/* Compact stat cards — dashboard, sales/reports/preorders/credits summaries */
.stats-grid--compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat-card--sm {
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.stat-card--sm .stat-card__icon {
  position: static;
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--brand-l);
  color: var(--gold);
  opacity: 1;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card--sm .stat-card__icon svg { width: 18px; height: 18px; }
.stat-card--sm .stat-card__body { min-width: 0; }
.stat-card--sm .stat-card__label {
  font-size: 0.68rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
}
.stat-card--sm .stat-card__value {
  font-size: 1.15rem;
  white-space: nowrap;
}
.stat-card--sm .stat-card__sub {
  font-size: 0.7rem;
  margin-top: 0.15rem;
}


/* === TABLES === */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  font-size: 0.88rem;
}
thead th {
  background: var(--cream);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  padding: 0.85rem 1rem;
  text-align: left;
  white-space: nowrap;
}
tbody td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: middle;
}
tbody tr:hover {
  background: rgba(232,72,63,0.03);
}
tbody tr:last-child td { border-bottom: none; }


/* === TABLES GRID (Dashboard) === */
.tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}


/* === BADGES === */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 20px;
}
.badge--success { background: rgba(40,167,69,0.1); color: var(--success); }
.badge--warning { background: rgba(240,173,78,0.12); color: #d48800; }
.badge--danger  { background: rgba(220,53,69,0.1); color: var(--danger); }
.badge--info    { background: rgba(74,144,217,0.1); color: var(--info); }


/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--gold);
  color: var(--white);
  border-color: var(--gold);
}
.btn-primary:hover {
  background: var(--gold-d);
  border-color: var(--gold-d);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(232,72,63,0.35);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: rgba(0,0,0,0.15);
}
.btn-secondary:hover {
  border-color: var(--gold);
  color: var(--gold-d);
}
.btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #c82333;
  transform: translateY(-1px);
}
.btn-success {
  background: var(--success);
  color: var(--white);
  border-color: var(--success);
}
.btn-success:hover {
  background: #218838;
  transform: translateY(-1px);
}
.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.75rem;
  border-radius: 6px;
}
.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1rem;
}
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }


/* === FORMS === */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--white);
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,72,63,0.15);
}
select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.5rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}

/* Read-only display field */
.form-display {
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  background: var(--cream);
  border: 1.5px solid rgba(0,0,0,0.06);
  border-radius: 8px;
  color: var(--brown);
  font-weight: 600;
}


/* === FILTERS === */
.filters,
.filters-bar {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: var(--cream);
  border-radius: var(--radius);
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters .form-group,
.filters-bar .form-group {
  margin-bottom: 0;
  min-width: 130px;
  max-width: 160px;
}
.filters-bar .form-group--btn {
  min-width: 0;
  max-width: none;
  display: flex;
  gap: 0.5rem;
}
.filters label,
.filters-bar label {
  font-size: 0.7rem;
  margin-bottom: 0.2rem;
}
.filters .form-control,
.filters-bar .form-control {
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
}
.filters-card .card__body {
  padding: 0;
}


/* === POS BILLING SYSTEM === */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.pos-left {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.pos-right { position: sticky; top: 1.5rem; }

/* Denser cards for the POS screen specifically */
.pos-card .card__header {
  padding: 0.85rem 1.1rem;
}
.pos-card .card__body {
  padding: 1.1rem;
}

/* Product search autocomplete */
.product-search-wrap { position: relative; }
.product-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 100;
  background: var(--white);
  border: 1.5px solid var(--cream-d);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 260px;
  overflow-y: auto;
}
.product-dropdown.open { display: block; }
.product-dropdown__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.1s;
}
.product-dropdown__item:hover {
  background: rgba(232,72,63,0.1);
}
.product-dropdown__item strong {
  color: var(--brown);
}
.product-dropdown__meta {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
  margin-left: 0.75rem;
}
.product-dropdown__add {
  padding: 0.55rem 0.85rem;
  background: var(--cream);
  border-top: 1px solid var(--cream-d);
  font-size: 0.8rem;
  text-align: center;
}
.product-dropdown__add a {
  color: var(--gold-d);
  text-decoration: none;
}
.product-dropdown__add a:hover {
  text-decoration: underline;
}

/* Quick product buttons */
.quick-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.4rem;
}
.quick-product-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.75rem 0.5rem;
  border: 1.5px solid var(--cream-d);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--brown);
  transition: all 0.15s;
}
.quick-product-btn small {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 400;
}
.quick-product-btn:hover {
  border-color: var(--gold);
  background: rgba(232,72,63,0.08);
  transform: translateY(-1px);
}

/* Bill card */
.bill-card {
  border: 2px solid var(--cream-d);
}
.bill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--cream-d);
}
.bill-header h3 { margin: 0; font-size: 1rem; }

/* Bill items list */
.bill-items {
  max-height: 320px;
  overflow-y: auto;
  padding: 0;
}
.bill-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-light);
}
.bill-empty p { font-size: 0.95rem; margin-bottom: 0.25rem; }
.bill-empty small { font-size: 0.75rem; }

.bill-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 0.85rem;
}
.bill-item:hover { background: rgba(232,72,63,0.04); }
.bill-item__name {
  font-weight: 600;
  color: var(--brown);
}
.bill-item__detail {
  font-size: 0.75rem;
  color: var(--text-light);
}
.bill-item__total {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  min-width: 70px;
  text-align: right;
}
.bill-item__remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: background 0.15s;
}
.bill-item__remove:hover { background: rgba(220,53,69,0.1); }

/* Bill totals */
.bill-totals {
  padding: 0.75rem 1.25rem;
  background: var(--cream);
  border-top: 2px solid var(--cream-d);
}
.bill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--text-light);
}
.bill-row--discount {
  font-size: 0.82rem;
}
.discount-input {
  width: 50px;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--cream-d);
  border-radius: 4px;
  font-size: 0.8rem;
  text-align: center;
  font-family: var(--font-sans);
}
.bill-row--total {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brown);
  border-top: 2px solid var(--gold);
  padding-top: 0.65rem;
  margin-top: 0.35rem;
}
.bill-row--items-count {
  font-size: 0.75rem;
  color: var(--text-light);
  justify-content: center;
}

/* Payment section */
.bill-payment {
  padding: 1rem 1.25rem;
}
.payment-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.payment-buttons--3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.pay-btn {
  opacity: 0.6;
  transition: all 0.15s;
}
.pay-btn.active {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--brown);
}

.paid-section, .credit-section {
  padding: 0.75rem 0;
}

.change-display {
  background: var(--cream);
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--success);
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.save-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.save-bill-btn {
  padding: 1rem;
  font-size: 1.05rem;
}
.save-bill-btn:disabled,
.save-invoice-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.save-invoice-btn {
  padding: 0.7rem;
  font-size: 0.9rem;
  border: 1.5px solid var(--gold);
  background: transparent;
  color: var(--brown);
  cursor: pointer;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 600;
  transition: all 0.15s;
}
.save-invoice-btn:hover:not(:disabled) {
  background: rgba(232,72,63,0.1);
}

/* Invoice view */
.invoice-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.invoice-meta__item .label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}
.invoice-meta__item .value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

table tfoot tr { border-top: 1px solid var(--cream-d); }
table tfoot td { padding: 0.5rem 0.75rem; }
table .total-row td {
  border-top: 2px solid var(--gold);
  font-weight: 700;
}

.form-control--lg {
  font-size: 1.15rem;
  padding: 0.75rem 1rem;
  font-weight: 600;
}


/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 420px;
  padding: 2rem;
  text-align: center;
}
.modal h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--brown);
  margin-bottom: 0.75rem;
}
.modal p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.modal .btn-group {
  justify-content: center;
}


/* === FLASH MESSAGES === */
.flash {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 600;
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: flashIn 0.4s ease;
  max-width: 400px;
}
.flash--success { background: #d4edda; color: #155724; }
.flash--danger  { background: #f8d7da; color: #721c24; }
.flash--warning { background: #fff3cd; color: #856404; }
.flash--info    { background: #d1ecf1; color: #0c5460; }
.flash__close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  line-height: 1;
}
.flash__close:hover { opacity: 1; }
@keyframes flashIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}


/* === LOGIN PAGE === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  padding: 1rem;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-card__brand {
  margin-bottom: 2rem;
}
.login-card__brand h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--brown);
}
.login-card__brand h1 span { color: var(--gold); }
.login-card__brand p {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-light);
  margin-top: 0.3rem;
}
.login-card .form-group { text-align: left; }
.login-card .form-control {
  padding: 0.8rem 1rem;
}
.login-error {
  background: rgba(220,53,69,0.08);
  color: var(--danger);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}


/* === SETUP PAGE === */
.setup-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  padding: 1rem;
}
.setup-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 500px;
}
.setup-card h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--brown);
  margin-bottom: 0.5rem;
}
.setup-card > p {
  font-size: 0.88rem;
  color: var(--text-light);
  margin-bottom: 2rem;
}
.setup-success {
  background: rgba(40,167,69,0.08);
  color: var(--success);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.setup-error {
  background: rgba(220,53,69,0.08);
  color: var(--danger);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}


/* === UTILITIES === */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: #d48800 !important; }
.text-muted  { color: var(--text-light) !important; }
.text-gold   { color: var(--gold) !important; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.fw-bold { font-weight: 700; }
.nowrap { white-space: nowrap; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-light);
}
.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.3;
}
.empty-state p {
  font-size: 0.9rem;
}

/* Search input in table headers */
.search-wrap {
  position: relative;
}
.search-wrap input {
  padding-left: 2.2rem;
}
.search-wrap::before {
  content: '';
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat center;
}


/* === SIDEBAR BADGE (Pre-order count) === */
.sidebar__badge {
  margin-left: auto;
  background: var(--danger);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0 6px;
  line-height: 1;
}

/* SVG icons inside sidebar */
.sidebar__icon svg {
  display: block;
  width: 18px;
  height: 18px;
}


/* === NOTIFICATION POPUP === */
.notification-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.notification-popup {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 460px;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.notification-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--danger);
  color: var(--white);
}
.notification-popup__header h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}
.notification-popup__close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}
.notification-popup__close:hover { opacity: 1; }
.notification-popup__body {
  padding: 1rem 1.25rem;
  max-height: 300px;
  overflow-y: auto;
}
.notification-popup__item {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.notification-popup__item:last-child { border-bottom: none; }
.notification-popup__item strong {
  display: block;
  color: var(--brown);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.notification-popup__item span {
  font-size: 0.8rem;
  color: var(--text-light);
  display: block;
  margin-bottom: 0.15rem;
}
.notification-popup__item .notif-time {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--danger);
}
.notification-popup__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid rgba(0,0,0,0.06);
  background: var(--cream);
}


/* === PRE-ORDER STYLES === */
.preorder-details {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-overdue {
  background: rgba(220,53,69,0.04) !important;
}
.row-overdue td:first-child {
  border-left: 3px solid var(--danger);
}

/* Quick reference product tags in pre-order form */
.quick-ref {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.quick-ref__tag {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--cream-d);
  color: var(--brown);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.quick-ref__tag:hover {
  background: rgba(232,72,63,0.2);
  border-color: var(--gold);
}

/* Pre-order notify info box */
.preorder-notify-info {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: rgba(74,144,217,0.08);
  border: 1px solid rgba(74,144,217,0.15);
  border-radius: 8px;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--info);
  line-height: 1.5;
}
.preorder-notify-info svg {
  flex-shrink: 0;
  margin-top: 2px;
}


/* === MILK RECORDS — DAILY ENTRY LIST (farmer-detail page) === */
.day-list-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding-bottom: 1rem;
}
.day-list-columns .day-list:first-child {
  border-right: 1px solid rgba(0,0,0,0.06);
}
.autosave-status {
  min-height: 1.4rem;
  padding: 0 1.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
}
.autosave-status--ok { color: var(--success); }
.autosave-status--error { color: var(--danger); }
.day-list {
  display: flex;
  flex-direction: column;
  padding: 0 1.5rem;
}
.day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  gap: 1rem;
}
.day-row:last-child { border-bottom: none; }
.day-row--today {
  background: var(--brand-l);
  margin: 0 -1.5rem;
  padding: 0.45rem 1.5rem;
  border-radius: 8px;
  border-bottom-color: transparent;
}
.day-row--disabled { opacity: 0.35; }
.day-row--header {
  border-bottom: 2px solid var(--cream-d);
  padding-bottom: 0.5rem;
}
.day-row--header .day-row__label,
.day-row--header .day-row__col-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}
.day-row__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brown);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 90px;
}
.day-row__input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.day-row__col-label {
  width: 90px;
  text-align: center;
}
.day-row__col-label--total { width: 60px; }
.day-row__input-group .form-control {
  width: 90px;
  text-align: right;
  padding: 0.4rem 0.6rem;
}
.day-row__row-total {
  width: 60px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-d);
}

.form-control--lg.text-center { text-align: center; }


/* === PAGE HEADER ACTIONS (Report buttons etc.) === */
.page-header__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.page-header__actions .btn {
  font-size: 0.78rem;
  padding: 0.45rem 1rem;
}


/* === RESPONSIVE === */
@media (max-width: 1024px) {
  .tables-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .day-list-columns {
    grid-template-columns: 1fr;
  }
  .day-list-columns .day-list:first-child {
    border-right: none;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show {
    display: block;
  }
  .topbar {
    display: flex;
  }
  .main-content {
    margin-left: 0;
    padding-top: calc(var(--topbar-h) + 1.5rem);
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .pos-layout {
    grid-template-columns: 1fr;
  }
  .pos-right {
    position: static;
  }
  .payment-buttons {
    grid-template-columns: 1fr;
  }
  .page-header h1 {
    font-size: 1.4rem;
  }
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .flash {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .login-card, .setup-card {
    padding: 2rem 1.5rem;
  }
}


/* === PRINTABLE REPORTS (milk/report.php) === */
.report-print-header {
  display: none;
}
.report-block { margin-bottom: 1.25rem; }

@media print {
  .sidebar, .topbar, .sidebar-overlay, .no-print, .flash {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  .report-print-header {
    display: block;
    margin-bottom: 1.5rem;
  }
  .report-print-header h1 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    color: var(--brown);
  }
  .report-print-header p {
    font-size: 0.9rem;
    color: var(--text-light);
  }
  .card {
    box-shadow: none !important;
    border: 1px solid rgba(0,0,0,0.1);
  }
  .report-block--farmer {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
