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

:root {
  --bg:        #0f1a0f;
  --bg2:       #1a2e1a;
  --bg3:       #243324;
  --surface:   #1e301e;
  --border:    #2d472d;
  --green:     #4caf50;
  --green-l:   #81c784;
  --blue:      #42a5f5;
  --orange:    #ffa726;
  --purple:    #ab47bc;
  --teal:      #26c6da;
  --red:       #ef5350;
  --text:      #e8f5e9;
  --text2:     #a5d6a7;
  --text3:     #6a9e6a;
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); }

/* ── LOGIN SCREEN ────────────────────────────────────────────────── */
.login-screen {
  display: flex; flex-direction: column; align-items: center;
  min-height: 100dvh; padding: 40px 20px 20px;
  background: radial-gradient(ellipse at 50% 0%, #1e4020 0%, var(--bg) 70%);
}

.login-header { text-align: center; margin-bottom: 40px; }
.pig-icon { font-size: 64px; margin-bottom: 8px; filter: drop-shadow(0 4px 12px rgba(76,175,80,.4)); }
.login-header h1 { font-size: 2.2rem; font-weight: 800; color: var(--green-l); letter-spacing: 2px; }
.login-header .subtitle { color: var(--text3); margin-top: 4px; font-size: .95rem; }

.user-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; width: 100%; max-width: 360px;
}
.user-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.user-card:active { transform: scale(.96); }
.user-card:hover  { border-color: var(--green); box-shadow: 0 0 16px rgba(76,175,80,.2); }
.user-avatar { font-size: 36px; margin-bottom: 8px; }
.user-name   { font-size: 1rem; font-weight: 600; color: var(--text); }

/* PIN Modal */
.pin-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(6px);
}
.pin-card {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 28px 24px;
  width: 320px; text-align: center;
  box-shadow: var(--shadow);
}
.pin-user-name { font-size: 1.3rem; font-weight: 700; color: var(--green-l); margin-bottom: 6px; }
.pin-label     { color: var(--text3); font-size: .9rem; margin-bottom: 18px; }

.pin-dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 24px; }
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent;
  transition: background .15s, border-color .15s;
}
.pin-dots span.filled { background: var(--green); border-color: var(--green); }

.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.pin-btn {
  height: 56px; border-radius: 12px; font-size: 1.3rem; font-weight: 600;
  background: var(--bg3); border: 1.5px solid var(--border);
  transition: background .1s, transform .1s;
}
.pin-btn:active { transform: scale(.92); background: var(--border); }
.pin-clear { color: var(--red); }
.pin-back  { color: var(--orange); }

.pin-error { color: var(--red); font-size: .85rem; min-height: 20px; margin-bottom: 10px; }
.btn-cancel {
  background: transparent; border: 1px solid var(--border);
  color: var(--text3); padding: 8px 24px; border-radius: 8px;
  font-size: .9rem; margin-top: 4px;
}

/* ── MENU SCREEN ─────────────────────────────────────────────────── */
.menu-screen { padding: 0 0 24px; }

.menu-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 12px;
}
.header-row { display: flex; justify-content: space-between; align-items: flex-start; }
.greeting   { font-size: .85rem; color: var(--text3); }
.user-badge { font-size: 1.15rem; font-weight: 700; color: var(--green-l); }
.date-badge { font-size: .8rem; color: var(--text3); margin-top: 6px; text-transform: capitalize; }
.logout-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text3); padding: 6px 14px; border-radius: 8px; font-size: .85rem;
}
.logout-btn:active { opacity: .7; }

.menu-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; padding: 20px;
}

.menu-card {
  border-radius: var(--radius);
  padding: 20px 16px;
  border: 1.5px solid transparent;
  position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  background: var(--surface);
}
.menu-card:active { transform: scale(.96); }
.menu-card::before {
  content:''; position:absolute; inset:0; opacity:.08;
  background: currentColor;
}
.card-green  { color: var(--green);  border-color: #2d4e2d; }
.card-blue   { color: var(--blue);   border-color: #1e3a5f; }
.card-orange { color: var(--orange); border-color: #4e3a1e; }
.card-purple { color: var(--purple); border-color: #3a1e4e; }
.card-teal   { color: var(--teal);   border-color: #1e4a4e; }
.card-red    { color: var(--red);    border-color: #4e1e1e; }

.card-icon  { font-size: 28px; margin-bottom: 10px; }
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.card-sub   { font-size: .78rem; color: var(--text3); line-height: 1.3; }
.card-badge {
  position: absolute; top: 10px; right: 10px;
  background: var(--red); color: #fff;
  border-radius: 50%; width: 22px; height: 22px;
  font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ── OFFLINE BANNER ──────────────────────────────────────────────── */
.offline-banner {
  margin: 0 20px; padding: 10px 14px;
  background: rgba(255,167,38,.15); border: 1px solid rgba(255,167,38,.3);
  border-radius: 10px; font-size: .85rem; color: var(--orange); text-align: center;
}

/* ── GENERIC PAGE LAYOUT ─────────────────────────────────────────── */
.page { padding: 0 0 80px; }
.page-header {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
}
.back-btn { font-size: 1.4rem; line-height: 1; }
.page-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.form-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.field-label { font-size: .8rem; color: var(--text3); margin-bottom: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.btn-primary {
  background: var(--green); color: #fff;
  border-radius: 12px; padding: 14px;
  font-size: 1rem; font-weight: 700;
  width: 100%; margin-top: 4px;
  transition: opacity .15s;
}
.btn-primary:active { opacity: .8; }
.btn-primary:disabled { opacity: .4; }

.info-box {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  font-size: .85rem; color: var(--text2);
}
.info-box b { color: var(--green-l); }

/* ── LIST CARDS ──────────────────────────────────────────────────── */
.list-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.record-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.record-card.done-card { opacity: .5; }
.record-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.record-sow { font-size: 1rem; font-weight: 700; color: var(--green-l); }
.record-date { font-size: .8rem; color: var(--text3); }
.record-med  { font-size: .9rem; color: var(--text); margin-bottom: 4px; }
.record-details { font-size: .8rem; color: var(--text3); }
.record-user { font-size: .75rem; color: var(--text3); margin-top: 6px; }

.done-btn {
  background: var(--green); color: #fff;
  border-radius: 8px; padding: 6px 14px;
  font-size: .8rem; font-weight: 600;
  margin-top: 8px;
}
.done-btn:active { opacity: .7; }

.condition-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}
.cond-good    { background: rgba(76,175,80,.2);  color: var(--green); }
.cond-medium  { background: rgba(255,167,38,.2); color: var(--orange); }
.cond-bad     { background: rgba(239,83,80,.2);  color: var(--red); }

.sl-card { border-left: 3px solid var(--red); }
.sl-days  { font-size: 1.2rem; font-weight: 800; color: var(--red); }
.sl-safe  { font-size: .8rem; color: var(--text3); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── TOAST ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 20px;
  border-radius: 24px; font-size: .9rem;
  box-shadow: var(--shadow); z-index: 999;
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity:0; transform: translate(-50%, 20px); } }

/* ── SCROLLBAR ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
