/* ==========================================
   MILK SYSTEM — Mobile App Stylesheet
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #1a4d2e;
  --primary-dk:   #0d3320;
  --primary-lt:   #2d6a4f;
  --accent:       #d4a017;
  --accent-lt:    #f0c040;
  --bg:           #eef2ee;
  --surface:      #ffffff;
  --surface2:     #f8fbf8;
  --text:         #111827;
  --text2:        #374151;
  --muted:        #6b7280;
  --border:       #e5e7eb;
  --danger:       #dc2626;
  --success:      #16a34a;
  --info:         #2563eb;
  --amber:        #d97706;
  --nav-h:        66px;
  --bar-h:        60px;
  --r-card:       16px;
  --r-btn:        12px;
  --shadow:       0 2px 12px rgba(0,0,0,.09);
  --shadow-lg:    0 8px 30px rgba(0,0,0,.15);
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── SCROLLABLE PAGE BODY ─── */
.page-body {
  padding-top: var(--bar-h);
  padding-bottom: calc(var(--nav-h) + 16px);
  min-height: 100vh;
}

/* ─── TOP APP BAR ─── */
.app-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--bar-h);
  background: var(--primary);
  display: flex; align-items: center;
  padding: 0 18px;
  gap: 14px;
  z-index: 90;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.app-bar .bar-icon { font-size: 1.5rem; }
.app-bar .bar-title { flex: 1; }
.app-bar .bar-title h1 { color: #fff; font-size: 1.05rem; font-weight: 800; }
.app-bar .bar-title p  { color: rgba(255,255,255,.6); font-size: .72rem; margin-top: 1px; }
.bar-action {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.12);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .9rem;
  text-decoration: none; border: none; cursor: pointer;
  transition: background .2s;
}
.bar-action:hover { background: rgba(255,255,255,.22); }
.bar-badge {
  background: var(--accent); color: var(--primary-dk);
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 900;
}

/* ─── BOTTOM NAVIGATION ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  display: flex;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,.1);
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; text-decoration: none;
  color: var(--muted); font-size: .68rem; font-weight: 700;
  letter-spacing: .01em;
  transition: color .2s; padding: 8px 4px;
  position: relative;
}
.nav-item i { font-size: 1.2rem; transition: transform .2s; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: scale(1.15); }
.nav-item.active::before {
  content: '';
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* ─── SECTION PADDING ─── */
.section { padding: 16px 14px 0; }
.section:first-child { padding-top: 18px; }

/* ─── SUMMARY HERO ─── */
.hero-card {
  background: linear-gradient(140deg, var(--primary-dk) 0%, var(--primary-lt) 100%);
  border-radius: var(--r-card);
  padding: 20px 18px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin: 0 14px 4px;
  box-shadow: var(--shadow-lg);
}
.hero-card::after {
  content: '🐄';
  position: absolute; right: 14px; bottom: -4px;
  font-size: 4.5rem; opacity: .12;
}
.hero-card .hero-label { font-size: .72rem; font-weight: 700; opacity: .65; text-transform: uppercase; letter-spacing: .1em; }
.hero-card .hero-val   { font-size: 2.1rem; font-weight: 900; line-height: 1.1; margin: 4px 0; }
.hero-card .hero-sub   { font-size: .8rem; opacity: .7; }
.hero-stats { display: flex; gap: 0; margin-top: 16px; border-top: 1px solid rgba(255,255,255,.15); padding-top: 14px; }
.hs-item { flex: 1; text-align: center; }
.hs-item + .hs-item { border-left: 1px solid rgba(255,255,255,.15); }
.hs-item .hv { font-size: 1.1rem; font-weight: 900; color: var(--accent-lt); }
.hs-item .hl { font-size: .65rem; opacity: .6; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; margin-top: 2px; }

/* ─── MINI STAT CARDS ─── */
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 14px; margin-bottom: 4px; }
.mini-card {
  background: var(--surface); border-radius: var(--r-card);
  padding: 16px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.mini-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.mini-icon.green { background: #dcfce7; }
.mini-icon.amber { background: #fef3c7; }
.mini-icon.blue  { background: #dbeafe; }
.mini-icon.red   { background: #fee2e2; }
.mini-val { font-size: 1.3rem; font-weight: 900; color: var(--text); }
.mini-lbl { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ─── SECTION HEADER ─── */
.sec-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px 10px;
}
.sec-header h2 { font-size: .88rem; font-weight: 800; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; }
.sec-header a { font-size: .8rem; color: var(--primary); font-weight: 700; text-decoration: none; }

/* ─── RECORD CARDS ─── */
.card-list { display: flex; flex-direction: column; gap: 10px; padding: 0 14px; }

.record-card {
  background: var(--surface); border-radius: var(--r-card);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform .15s;
  active { transform: scale(.98); }
}
.record-card:active { transform: scale(.98); }

.rc-top {
  display: flex; align-items: center;
  padding: 14px 16px; gap: 12px;
}
.rc-avatar {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1rem; flex-shrink: 0;
}
.rc-avatar.kharcha { background: linear-gradient(135deg,#b45309,#d97706); }
.rc-info { flex: 1; min-width: 0; }
.rc-name  { font-weight: 800; font-size: .95rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-sub   { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.rc-right { text-align: right; flex-shrink: 0; }
.rc-amount { font-size: 1rem; font-weight: 900; color: var(--primary); }
.rc-date   { font-size: .72rem; color: var(--muted); margin-top: 2px; }

.rc-actions {
  display: flex; border-top: 1px solid var(--border);
}
.rc-btn {
  flex: 1; padding: 10px; border: none; background: transparent;
  font-family: 'Nunito', sans-serif; font-size: .8rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 6px; transition: background .15s; text-decoration: none; color: var(--text2);
}
.rc-btn:active { background: var(--bg); }
.rc-btn + .rc-btn { border-left: 1px solid var(--border); }
.rc-btn.edit   { color: var(--amber); }
.rc-btn.delete { color: var(--danger); }
.rc-btn.view   { color: var(--primary); }

/* ─── HORIZONTAL SCROLL TABS ─── */
.scroll-tabs {
  display: flex; overflow-x: auto; gap: 8px;
  padding: 0 14px 0; margin-bottom: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scroll-tabs::-webkit-scrollbar { display: none; }
.stab {
  flex-shrink: 0; padding: 8px 18px;
  border-radius: 20px;
  font-size: .82rem; font-weight: 800;
  text-decoration: none; border: 2px solid transparent;
  transition: all .2s;
  background: var(--surface); color: var(--muted);
  box-shadow: var(--shadow);
}
.stab.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}

/* ─── FILTER BAR ─── */
.filter-bar {
  background: var(--surface); border-radius: var(--r-card);
  margin: 0 14px 14px; padding: 14px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.filter-row { display: flex; gap: 8px; align-items: flex-end; }
.filter-group { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.filter-group select,
.filter-group input { width: 100%; }

/* ─── FORM ELEMENTS ─── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
label.form-label { font-size: .78rem; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; }
input[type=text], input[type=password],
input[type=date], input[type=number],
input[type=month], select, textarea {
  width: 100%; padding: 13px 14px;
  border: 2px solid var(--border); border-radius: var(--r-btn);
  font-family: 'Nunito', sans-serif; font-size: .95rem;
  color: var(--text); background: var(--surface2);
  outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-lt);
  box-shadow: 0 0 0 3px rgba(45,106,79,.12);
  background: #fff;
}
textarea { resize: vertical; min-height: 70px; }
.calc-display {
  padding: 12px 14px;
  background: #f0fdf4; border: 2px solid #86efac;
  border-radius: var(--r-btn);
  font-weight: 900; color: var(--primary);
  font-size: 1rem; text-align: center;
}

/* ─── BUTTONS ─── */
.btn-full {
  width: 100%; padding: 15px;
  border: none; border-radius: var(--r-btn);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem; font-weight: 800;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px;
  transition: all .2s; letter-spacing: .02em;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-lt); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 2px solid var(--border) !important;
}
.btn-outline:active { background: var(--bg); }
.btn-amber   { background: var(--amber); color: #fff; }

/* ─── FAB ─── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 18px;
  width: 56px; height: 56px;
  background: var(--primary);
  color: #fff; font-size: 1.5rem;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(26,77,46,.45);
  border: none; cursor: pointer;
  transition: all .2s; z-index: 80;
  text-decoration: none;
}
.fab:active { transform: scale(.92); box-shadow: 0 3px 10px rgba(26,77,46,.3); }

/* ─── BOTTOM SHEET ─── */
.sheet-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 200;
  backdrop-filter: blur(2px);
}
.sheet-overlay.open { display: block; }

.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 0 0 env(safe-area-inset-bottom, 20px);
  z-index: 201;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,.72,0,1);
  max-height: 92vh;
  display: flex; flex-direction: column;
}
.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border); border-radius: 2px;
  margin: 14px auto 0;
  flex-shrink: 0;
}
.sheet-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.sheet-header h3 { font-size: 1.05rem; font-weight: 800; color: var(--text); }
.sheet-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .9rem;
}
.sheet-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet-actions { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }

/* ─── FLASH MESSAGES ─── */
.flash-msg {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-radius: 12px;
  font-weight: 700; font-size: .9rem;
  margin: 0 14px 4px;
}
.flash-msg.success { background: #f0fdf4; border: 1px solid #86efac; color: var(--success); }
.flash-msg.error   { background: #fef2f2; border: 1px solid #fca5a5; color: var(--danger); }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center; padding: 50px 30px;
  color: var(--muted);
}
.empty-state .es-icon { font-size: 3.5rem; margin-bottom: 14px; opacity: .35; }
.empty-state h3 { font-size: 1rem; font-weight: 800; color: var(--text2); margin-bottom: 6px; }
.empty-state p  { font-size: .85rem; }

/* ─── TOTAL SUMMARY BAR ─── */
.total-bar {
  background: var(--primary); color: #fff;
  border-radius: var(--r-card); padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 14px 8px; box-shadow: var(--shadow);
}
.total-bar .tb-label { font-size: .78rem; opacity: .75; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.total-bar .tb-val   { font-size: 1.25rem; font-weight: 900; }
.total-bar .tb-sub   { font-size: .75rem; opacity: .65; margin-top: 1px; }

/* ─── BADGE ─── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: .7rem; font-weight: 800; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red   { background: #fee2e2; color: #dc2626; }
.badge-blue  { background: #dbeafe; color: #1d4ed8; }
.badge-amber { background: #fef3c7; color: #92400e; }

/* ─── DATE CHIP ─── */
.date-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #f0fdf4; color: var(--primary);
  border-radius: 20px; padding: 4px 10px;
  font-size: .75rem; font-weight: 700;
}

/* ─── LOGIN PAGE ─── */
.login-page {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--primary-dk);
}
.login-top {
  flex: 0 0 38vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px 30px;
  background: linear-gradient(160deg, var(--primary-dk), var(--primary-lt));
}
.login-cow { font-size: 5rem; margin-bottom: 16px; filter: drop-shadow(0 6px 20px rgba(0,0,0,.35)); animation: sway 3s ease-in-out infinite; }
@keyframes sway { 0%,100%{transform:rotate(-3deg)} 50%{transform:rotate(3deg)} }
.login-title { font-size: 1.6rem; font-weight: 900; color: #fff; text-align: center; letter-spacing: -.01em; }
.login-sub   { font-size: .85rem; color: rgba(255,255,255,.6); margin-top: 6px; text-align: center; }
.login-form-wrap {
  flex: 1; background: #fff; border-radius: 28px 28px 0 0;
  padding: 30px 24px 32px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.2);
}
.login-form-wrap h2 { font-size: 1.3rem; font-weight: 900; color: var(--text); margin-bottom: 4px; }
.login-form-wrap p  { font-size: .85rem; color: var(--muted); margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.input-wrap { position: relative; }
.input-wrap i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; }
.input-wrap input { padding-left: 40px; }
.error-card {
  background: #fef2f2; border: 1px solid #fca5a5;
  border-radius: 12px; padding: 12px 14px;
  color: var(--danger); font-size: .85rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

/* ─── CONFIRM DIALOG ─── */
.confirm-sheet { }

/* ─── MISC ─── */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.text-muted { color: var(--muted); font-size: .82rem; }
.fw-900 { font-weight: 900; }
.color-primary { color: var(--primary); }
.color-danger  { color: var(--danger); }
.color-amber   { color: var(--amber); }

/* ─── MONTH PICKER STRIP ─── */
.month-strip { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.month-strip input[type=month] { flex: 1; }
.month-strip button { padding: 11px 16px; border: none; background: var(--primary); color: #fff; border-radius: 10px; font-family: 'Nunito',sans-serif; font-weight: 800; font-size: .85rem; cursor: pointer; }

/* ─── SCROLLABLE CONTENT ─── */
.scroll-content { overflow-y: auto; }

/* ─── TRANSITION ─── */
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
