/* ================================================================
   DRY STORE MANAGER — Main Stylesheet
   Mobile-first, responsive
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:   #1a56db;
  --primary-d: #1342b0;
  --accent:    #0ea5e9;
  --success:   #16a34a;
  --warning:   #d97706;
  --danger:    #dc2626;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --sidebar-w: 230px;
  --topbar-h:  56px;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
}

body { font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 1000; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.app-logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -.3px; }
.menu-toggle { background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.menu-toggle:hover { background: rgba(255,255,255,.15); }
.role-badge { background: rgba(255,255,255,.18); padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; display: none; }
.user-name { font-size: .88rem; display: none; }
.btn-logout { background: rgba(255,255,255,.18); color: #fff; padding: 6px 14px; border-radius: 6px; text-decoration: none; font-size: .82rem; font-weight: 600; transition: background .2s; }
.btn-logout:hover { background: rgba(255,255,255,.3); }

@media(min-width:600px) { .role-badge, .user-name { display: inline; } }

/* ── LAYOUT ──────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; padding-top: var(--topbar-h); }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: #1e293b; color: #cbd5e1;
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  transform: translateX(-100%); transition: transform .25s ease;
  z-index: 900; overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-inner { padding: 20px 0 40px; }
.nav-section { font-size: .7rem; font-weight: 700; letter-spacing: 1px; color: #475569; padding: 16px 20px 6px; text-transform: uppercase; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #94a3b8; text-decoration: none; font-size: .92rem; transition: all .18s; }
.nav-link:hover { background: #334155; color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-footer { padding: 20px; font-size: .75rem; color: #475569; margin-top: 20px; border-top: 1px solid #334155; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 850; }
.sidebar-overlay.show { display: block; }

@media(min-width:900px) {
  .sidebar { transform: translateX(0); }
  .content { margin-left: var(--sidebar-w); }
  #menuToggle { display: none; }
}

/* ── CONTENT ─────────────────────────────────────────────────── */
.content { flex: 1; padding: 24px 16px; max-width: 100%; }
@media(min-width:768px) { .content { padding: 28px 24px; } }

/* ── CARDS ───────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.page-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }

/* ── STATS GRID ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.stat-value { font-size: 1.7rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: 4px; }

/* ── FORMS ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .95rem; background: #fff; color: var(--text); transition: border-color .2s;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
input.error { border-color: var(--danger); }
.field-error { font-size: .78rem; color: var(--danger); margin-top: 3px; }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border: none; border-radius: 8px; font-size: .92rem; font-weight: 600; cursor: pointer; transition: all .18s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── ALERTS ──────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* ── TABLES ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th { background: #1e293b; color: #fff; padding: 11px 12px; text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover { background: #eff6ff; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.category-row td { background: #e0f2fe; font-weight: 700; font-size: .8rem; color: #0369a1; padding: 6px 12px; }

/* ── STATUS BADGES ───────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.badge-draft     { background: #fef9c3; color: #92400e; }
.badge-submitted { background: #dcfce7; color: #15803d; }
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-inactive  { background: #fee2e2; color: #b91c1c; }

/* ── STOCK ENTRY TABLE ───────────────────────────────────────── */
.entry-table th, .entry-table td { padding: 9px 10px; vertical-align: middle; }
.entry-table input[type=number] { padding: 7px 8px; font-size: .9rem; }
.entry-table .auto-cell { background: #f0fdf4; color: var(--success); font-weight: 700; text-align: center; }
.entry-table .opening-cell { text-align: center; font-weight: 600; color: var(--primary); }
.cat-header { background: #1e293b !important; color: #94a3b8 !important; font-size: .75rem !important; letter-spacing: 1px; }

/* ── LOGIN PAGE ──────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #1e293b 0%, var(--primary) 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; font-size: 3rem; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.login-sub   { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 28px; }

/* ── MISC UTILS ──────────────────────────────────────────────── */
.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-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.text-center { text-align: center; } .text-right { text-align: right; } .text-muted { color: var(--muted); }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }
.font-bold { font-weight: 700; } .d-flex { display: flex; } .align-center { align-items: center; }
.justify-between { justify-content: space-between; } .gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.text-sm { font-size: .82rem; }
.locked-notice { background: #fef9c3; border: 1.5px solid #fde68a; border-radius: 8px; padding: 12px 16px; font-size: .88rem; color: #92400e; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* ── WEEK NAV ────────────────────────────────────────────────── */
.week-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.week-nav a { text-decoration: none; }

/* Modal */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* Spinner */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
