/* ==========================================================
   Goldairy Milk Supply — Complete Design System
   ========================================================== */

:root {
  /* Brand colors */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --accent:         #f59e0b;

  /* Neutrals */
  --gray-50:   #f9fafb;
  --gray-100:  #f3f4f6;
  --gray-200:  #e5e7eb;
  --gray-300:  #d1d5db;
  --gray-400:  #9ca3af;
  --gray-500:  #6b7280;
  --gray-600:  #4b5563;
  --gray-700:  #374151;
  --gray-800:  #1f2937;
  --gray-900:  #111827;

  /* Layout */
  --topbar-h:  62px;
  --sidebar-w: 250px;
  --radius:    10px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--gray-800);
  background: var(--gray-100);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 { color: var(--gray-900); font-weight: 700; line-height: 1.25; }
h1 { font-size: 24px; margin-bottom: 6px; }
h2 { font-size: 18px; margin: 28px 0 14px; }
h3 { font-size: 16px; margin: 20px 0 10px; }

p { margin-bottom: 12px; }

.muted { color: var(--gray-500); font-size: 13px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-16 { margin-bottom: 16px; }

/* ==========================================================
   AUTH PAGES (login / landing)
   ========================================================== */
.landing,
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 20% 0%, #e0efff 0%, transparent 55%),
    radial-gradient(circle at 80% 100%, #fef3c7 0%, transparent 45%),
    linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
}
.login-card h1 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 4px;
}
.login-card .sub {
  text-align: center;
  color: var(--gray-500);
  font-size: 13px;
  margin-bottom: 24px;
}
.login-card .alt-link {
  text-align: center;
  font-size: 13px;
  margin-top: 18px;
  color: var(--gray-500);
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

/* ==========================================================
   TOPBAR
   ========================================================== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: #eeeabe;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar .brand {
  font-weight: 800;
  font-size: 16px;
  color: var(--gray-900);
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand:hover { text-decoration: none; color: var(--gray-900); }

.topbar .spacer { flex: 1; }

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--gray-600);
}

.topbar .btn-logout {
  padding: 7px 14px;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.topbar .btn-logout:hover {
  background: var(--danger-light);
  color: var(--danger);
  text-decoration: none;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--gray-700);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.menu-toggle:hover { background: var(--gray-100); }

/* ==========================================================
   SIDEBAR
   ========================================================== */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  padding: 16px 12px;
  overflow-y: auto;
  z-index: 90;
  transition: transform .25s ease;
}

.sidebar a {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--gray-700);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidebar a:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  text-decoration: none;
}
.sidebar a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37,99,235,.25);
}
.sidebar a.active:hover { background: var(--primary-dark); color: #fff; }

.sidebar .section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  padding: 16px 14px 8px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,.4);
  z-index: 85;
}

/* ==========================================================
   MAIN CONTENT
   ========================================================== */
.layout { min-height: 100vh; }

.content {
  margin-top: var(--topbar-h);
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-height: calc(100vh - var(--topbar-h));
  max-width: 1400px;
}

/* ==========================================================
   CARDS
   ========================================================== */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.card-header h2 { margin: 0; }

/* ==========================================================
   STATS
   ========================================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--primary);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card.green { border-left-color: var(--success); }
.stat-card.amber { border-left-color: var(--accent); }
.stat-card.red   { border-left-color: var(--danger); }

.stat-card .label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.02em;
  line-height: 1.1;
}
.stat-card .sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 6px;
}

/* ==========================================================
   BUTTONS
   ========================================================== */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  color: #fff;
  background: var(--primary);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .05s;
  white-space: nowrap;
  text-decoration: none;
}
button:hover,
.btn:hover {
  background: var(--primary-dark);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(37,99,235,.25);
}
button:active,
.btn:active { transform: translateY(1px); }

button:disabled { opacity: .55; cursor: not-allowed; }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: none;
}

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  box-shadow: none;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #15803d; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ==========================================================
   FORMS
   ========================================================== */
form .form-group,
.form-group {
  margin-bottom: 16px;
}

label,
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="tel"],
input[type="search"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%236b7280' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

input::placeholder,
textarea::placeholder { color: var(--gray-400); }

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.search-bar input { max-width: 320px; }

/* ==========================================================
   TABLES
   ========================================================== */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--gray-50);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

td.num,
th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-empty {
  text-align: center;
  color: var(--gray-400);
  padding: 40px 20px !important;
}

/* ==========================================================
   BADGES
   ========================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-green { background: var(--success-light); color: #166534; }
.badge-red   { background: var(--danger-light);  color: #991b1b; }
.badge-amber { background: var(--warning-light); color: #92400e; }
.badge-blue  { background: var(--primary-light); color: #1e40af; }
.badge-gray  { background: var(--gray-200);      color: var(--gray-700); }

/* ==========================================================
   ALERTS
   ========================================================== */
.ok, .err, .warn, .info {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ok   { background: var(--success-light); color: #166534; border-color: var(--success); }
.err  { background: var(--danger-light);  color: #991b1b; border-color: var(--danger); }
.warn { background: var(--warning-light); color: #92400e; border-color: var(--warning); }
.info { background: var(--primary-light); color: #1e40af; border-color: var(--primary); }

/* ==========================================================
   PAGINATION / MISC
   ========================================================== */
.pagination {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 500;
}
.pagination a:hover { background: var(--gray-100); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.open { display: block; }
  .content { margin-left: 0; padding: 20px 16px; }
  .menu-toggle { display: inline-flex; align-items: center; }
  .topbar { padding: 0 16px; }
  .topbar .user-info span:not(.badge) { display: none; }
  h1 { font-size: 20px; }
  .stat-card .value { font-size: 22px; }
  .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .login-card { padding: 28px 22px; }
  .card { padding: 18px; }
  th, td { padding: 10px 12px; }
}

/* Force uniform inputs on login pages */
.login-card input:not([type="hidden"]) {
  display: block;
  width: 100%;
  padding: 10px 13px;
  font-size: 14px;
  color: var(--gray-900);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.login-card input:not([type="hidden"]):focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

@media (max-width: 600px) {
  /* Make 3-column stats fit on mobile */
  .stats[style*="grid-template-columns: repeat(3, 1fr)"] .stat-card {
    padding: 10px 8px;
  }
  .stats[style*="grid-template-columns: repeat(3, 1fr)"] .stat-card .label {
    font-size: 9px;
    letter-spacing: 0;
    white-space: normal;
    line-height: 1.2;
  }
  .stats[style*="grid-template-columns: repeat(3, 1fr)"] .stat-card .value {
    font-size: 15px;
  }
}