:root{
  --bg:#f3f6fb;
  --surface:#ffffff;
  --surface-2:#fbfcfe;
  --text:#111827;
  --muted:#566072;
  --border:#dbe3ef;

  --brand:#1f4e8c;
  --brand-2:#2a6bb7;
  --brand-soft: rgba(31,78,140,.12);

  --danger:#b42318;
  --success:#0f766e;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 12px 30px rgba(17,24,39,.10);
  --shadow-soft: 0 8px 18px rgba(17,24,39,.08);
}

*{ box-sizing:border-box; }
[hidden]{ display:none !important; }

html,body{ height:100%; }
body{
  margin:0;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(31,78,140,.08), transparent 60%),
    radial-gradient(800px 520px at 90% 0%, rgba(42,107,183,.08), transparent 55%),
    var(--bg);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Top bar */
.topbar{
  position: sticky;
  top:0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,.82);
  border-bottom: 1px solid rgba(219,227,239,.85);
}
.header{
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}
.brand{
  display:flex;
  align-items:center;
  gap:12px;
}
.brand-mark{
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 22px rgba(31,78,140,.25);
}
h1{
  margin:0;
  font-size: 16px;
  font-weight: 820;
  letter-spacing: .2px;
}
.sub{
  margin:4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.header-actions{ display:flex; gap:10px; align-items:center; }

/* Layout */
.container{
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}
.muted{ color: var(--muted); font-size: 13px; }
.small{ font-size: 12px; }

.card{
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid rgba(219,227,239,.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}
.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 12px;
}
h2{
  margin:0;
  font-size: 14px;
  font-weight: 820;
}

/* Buttons */
.btn{
  border: 1px solid rgba(219,227,239,.95);
  background: rgba(255,255,255,.92);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  cursor:pointer;
  box-shadow: 0 6px 16px rgba(17,24,39,.08);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover{ transform: translateY(-1px); box-shadow: 0 10px 22px rgba(17,24,39,.10); }
.btn:active{ transform: translateY(0px); }

.btn.primary{
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  border-color: rgba(31,78,140,.35);
  color: #fff;
}
.btn.ghost{ background: transparent; box-shadow:none; }
.btn.danger{ border-color: rgba(180,35,24,.28); color: var(--danger); }

.bigbtn{
  width:100%;
  border: 1px solid rgba(219,227,239,.95);
  background: rgba(255,255,255,.94);
  border-radius: 22px;
  padding: 16px;
  text-align:left;
  cursor:pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .12s ease, box-shadow .12s ease;
}
.bigbtn:hover{ transform: translateY(-1px); box-shadow: var(--shadow); }
.bigbtn-title{ font-weight: 860; font-size: 16px; color: var(--brand); }
.bigbtn-sub{ margin-top:6px; color: var(--muted); font-size: 13px; }

.home-grid{ display:grid; gap:12px; }
@media (min-width: 780px){
  .home-grid{ grid-template-columns: repeat(3, 1fr); }
}
.home-foot{ margin-top: 14px; display:flex; justify-content:flex-end; }

.row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }

/* Inputs */
.field{ display:block; margin: 12px 0; }
.field span{
  display:block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}
input[type="password"], input[type="date"]{
  width:100%;
  border: 1px solid rgba(219,227,239,.95);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  font-size: 15px;
  background: rgba(255,255,255,.98);
  color: var(--text);
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease;
}
input:focus{
  border-color: rgba(31,78,140,.45);
  box-shadow: 0 0 0 6px var(--brand-soft);
}

/* Login */
.login{
  display:flex;
  justify-content:center;
  align-items:center;
  min-height: calc(100vh - 150px);
}
.login-card{
  width: min(520px, 92vw);
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
  padding: 18px;
}
.login-title{ font-size: 18px; font-weight: 900; letter-spacing: .2px; color: var(--brand); }

/* Counters */
.counter{ margin: 14px 0; padding: 12px; border: 1px solid rgba(219,227,239,.95); border-radius: 18px; background: rgba(255,255,255,.82); }
.counter-label{ font-weight: 780; margin-bottom: 10px; color: var(--text); }
.stepper{
  display:grid;
  grid-template-columns: 64px 1fr 64px;
  gap:10px;
  align-items:center;
}
.step{
  height: 54px;
  border-radius: 18px;
  border: 1px solid rgba(219,227,239,.95);
  background: rgba(31,78,140,.06);
  color: var(--brand);
  font-size: 28px;
  font-weight: 900;
  cursor:pointer;
}
.step:active{ transform: translateY(1px); }
.num{
  height: 54px;
  display:flex;
  align-items:center;
  justify-content:center;
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  font-size: 26px;
  font-weight: 900;
  color: var(--text);
}

.total-line{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 12px 12px;
  border-radius: 18px;
  border: 1px solid rgba(31,78,140,.22);
  background: rgba(31,78,140,.06);
}
.total-label{ font-weight: 780; color: var(--muted); }
.total-num{ font-weight: 950; font-size: 24px; color: var(--brand); }

/* List */
.list{ display:flex; flex-direction:column; gap:10px; }
.item{
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255,255,255,.90);
}
.item-top{ display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.item-title{ font-weight: 900; }
.item-meta{ margin-top: 5px; color: var(--muted); font-size: 12px; }
.item-actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.icon-btn{
  border: 1px solid rgba(219,227,239,.95);
  background: rgba(255,255,255,.95);
  border-radius: 14px;
  padding: 8px 10px;
  font-size: 13px;
  cursor:pointer;
}

/* Chart */
.chart-wrap{ margin-top: 8px; }
.chart{
  width:100%;
  height: 320px;
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  overflow:hidden;
}
.chart-legend{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0 10px;
}
.dot{ width:10px; height:10px; border-radius:999px; display:inline-block; }
.dot.saal{ background: rgba(31,78,140,.75); }
.dot.zoom{ background: rgba(15,118,110,.75); }
.dot.total{ background: rgba(180,35,24,.65); }

.stats-actions{ display:flex; gap:10px; }

/* Modal */
.modal{ border:none; padding:0; background:transparent; }
.modal::backdrop{ background: rgba(17,24,39,.35); }
.modal-inner{
  width: min(620px, 92vw);
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.modal-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.modal-body{ margin-top:10px; }
.modal-actions{ display:flex; justify-content:flex-end; margin-top: 14px; }

.warn{
  max-width: 980px;
  margin: 16px auto 14px;
  padding: 12px 14px;
  border: 1px solid rgba(180,35,24,.28);
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 24px rgba(17,24,39,.06);
}
code{
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(219,227,239,.95);
  background: rgba(255,255,255,.96);
}


/* Toast */
.toast{
  margin-left:auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(31,78,140,.25);
  background: rgba(31,78,140,.08);
  color: var(--brand);
  font-weight: 800;
  font-size: 12px;
  display:none;
}
.toast.show{ display:inline-flex; }


/* Date picker bigger (mobile-friendly) */
input[type="date"]{
  font-size: 18px;
  padding: 14px 14px;
  border-radius: 16px;
  min-height: 56px;
}


/* Stepper touch fix (prevent iOS double-tap zoom) */
.step{
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}


/* Manage tabs */
.btn.active-tab{
  background: rgba(31,78,140,.10);
  border-color: rgba(31,78,140,.25);
  color: var(--brand);
  box-shadow: none;
}


/* Date overflow fix v9 (iPhone) */
.field input[type="date"]{
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}


.step{
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.step.alt{
  font-size: 12px;
  padding: 10px 10px;
  border-radius: 14px;
}


/* Segmented range control */
.seg{
  display:inline-flex;
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 999px;
  overflow:hidden;
  background: rgba(255,255,255,.9);
}
.seg-btn{
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.seg-btn.active{
  background: rgba(31,78,140,.10);
  color: var(--brand);
  font-weight: 800;
}

/* Averages */
.avg-grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
  margin: 8px 0 12px;
}
.avg{
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255,255,255,.85);
}
.avg-num{
  font-size: 18px;
  font-weight: 950;
  color: var(--brand);
}
.avg-label{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.trend{
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255,255,255,.85);
  margin: 6px 0 12px;
}
.trend-title{
  font-weight: 900;
  margin-bottom: 8px;
}
.trend-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px 14px;
}
.trend-item{ font-size: 13px; }


/* Prominent toast popup */
.toast-root{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9999;
  display:flex;
  gap:10px;
  flex-direction:column;
  pointer-events:none;
}
.toast{
  pointer-events:none;
  min-width: min(520px, calc(100vw - 24px));
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(15,118,110,.25);
  background: rgba(255,255,255,.96);
  box-shadow: 0 18px 45px rgba(17,24,39,.18);
  font-weight: 850;
  color: var(--text);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.toast.success{
  border-color: rgba(15,118,110,.35);
  background: rgba(15,118,110,.08);
}
.toast.error{
  border-color: rgba(180,35,24,.35);
  background: rgba(180,35,24,.08);
}
.toast .msg{ font-size: 14px; }
.toast .badge{
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(219,227,239,.95);
  padding: 6px 10px;
  border-radius: 999px;
}


/* Charts layout */
.charts-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap:12px;
}
@media (min-width: 820px){
  .charts-grid{
    grid-template-columns: 2fr 1fr;
    align-items:start;
  }
}
.chart-card{
  border: 1px solid rgba(219,227,239,.95);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255,255,255,.85);
}
.legend{
  display:flex;
  gap:14px;
  flex-wrap:wrap;
  align-items:center;
  margin-bottom: 10px;
}
.leg{ display:flex; align-items:center; gap:8px; font-size: 13px; color: var(--text); font-weight: 800; }
.dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display:inline-block;
}
.dot.saal{ background: rgba(31,78,140,.85); }
.dot.zoom{ background: rgba(15,118,110,.85); }
.dot.total{ background: rgba(180,35,24,.75); }

.pie{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height: 220px;
}
.pie-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 8px;
}
.pie-title{
  font-weight: 950;
}
.pie-legend{
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 800;
}
.pie-legend > div{
  display:flex;
  align-items:center;
  gap:8px;
  color: var(--text);
}


/* ===============================
   v12 Theme: "Calm Modern" (JW-inspired)
   - richer palette (navy, teal, purple accents)
   - soft gradients + glass cards
   - subtle motion
   =============================== */

:root{
  --brand: #1f4e8c;           /* deep jw-like blue */
  --brand-2: #6d28d9;         /* purple accent */
  --brand-3: #0f766e;         /* teal */
  --danger: #b42318;

  --bg0: #f6f8fc;
  --bg1: #ffffff;
  --text: #111827;
  --muted: rgba(86,96,114,.92);

  --ring: rgba(109,40,217,.25);
  --border: rgba(219,227,239,.95);
  --shadow: 0 18px 45px rgba(17,24,39,.12);
  --shadow2: 0 10px 22px rgba(17,24,39,.10);
}

body{
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(31,78,140,.14), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, rgba(109,40,217,.12), transparent 55%),
    radial-gradient(900px 700px at 20% 120%, rgba(15,118,110,.10), transparent 55%),
    linear-gradient(180deg, var(--bg0), #f9fbff);
  color: var(--text);
}

.header{
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header h1{
  letter-spacing: -0.02em;
}
.sub{
  color: rgba(86,96,114,.9);
}

/* Cards */
.card{
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow2);
}
.card:hover{
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.card, .btn, .step, input, textarea, select{
  transition: box-shadow .18s ease, transform .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

/* Buttons */
.btn{
  border-radius: 16px;
  font-weight: 900;
  border: 1px solid rgba(31,78,140,.22);
  background: linear-gradient(180deg, rgba(31,78,140,.10), rgba(31,78,140,.06));
  color: var(--brand);
  box-shadow: 0 10px 18px rgba(31,78,140,.10);
}
.btn:hover{
  transform: translateY(-1px);
  border-color: rgba(31,78,140,.32);
  box-shadow: 0 16px 28px rgba(31,78,140,.14);
}
.btn:active{
  transform: translateY(0px) scale(.99);
}

.btn.ghost{
  background: rgba(255,255,255,.7);
  color: rgba(17,24,39,.92);
  border-color: rgba(219,227,239,.95);
  box-shadow: none;
}
.btn.ghost:hover{
  background: rgba(255,255,255,.9);
  border-color: rgba(31,78,140,.18);
  box-shadow: 0 12px 22px rgba(17,24,39,.10);
}

.btn.danger{
  background: linear-gradient(180deg, rgba(180,35,24,.12), rgba(180,35,24,.06));
  color: var(--danger);
  border-color: rgba(180,35,24,.25);
}

/* Accent buttons (for actions) */
.btn.primary{
  background: linear-gradient(180deg, rgba(109,40,217,.16), rgba(31,78,140,.08));
  color: rgba(17,24,39,.95);
  border-color: rgba(109,40,217,.22);
}
.btn.primary:hover{
  border-color: rgba(109,40,217,.35);
  box-shadow: 0 18px 35px rgba(109,40,217,.18);
}

/* Inputs */
.field input, .field textarea, .field select, input[type="date"], input[type="number"]{
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 16px rgba(17,24,39,.06);
}
.field input:focus, .field textarea:focus, .field select:focus, input[type="date"]:focus, input[type="number"]:focus{
  outline: none;
  border-color: rgba(109,40,217,.35);
  box-shadow: 0 0 0 4px var(--ring), 0 12px 22px rgba(17,24,39,.08);
}

/* Steppers */
.step{
  border-radius: 18px;
  border: 1px solid rgba(31,78,140,.20);
  background: linear-gradient(180deg, rgba(31,78,140,.10), rgba(31,78,140,.06));
  color: var(--brand);
  box-shadow: 0 12px 18px rgba(31,78,140,.10);
}
.step:hover{
  border-color: rgba(109,40,217,.22);
  box-shadow: 0 18px 28px rgba(109,40,217,.14);
}
.step.alt{
  border-color: rgba(15,118,110,.18);
  background: linear-gradient(180deg, rgba(15,118,110,.10), rgba(15,118,110,.06));
  color: var(--brand-3);
}

/* Segmented control */
.seg{
  border-color: rgba(109,40,217,.18);
  background: rgba(255,255,255,.75);
}
.seg-btn.active{
  background: linear-gradient(180deg, rgba(109,40,217,.16), rgba(31,78,140,.08));
  color: rgba(17,24,39,.95);
  font-weight: 950;
}

/* Stats / avg cards */
.avg{
  background: rgba(255,255,255,.82);
  border-color: rgba(219,227,239,.95);
  box-shadow: 0 10px 18px rgba(17,24,39,.08);
}
.avg-num{ color: var(--brand-2); }

/* Trend */
.trend{
  background: linear-gradient(180deg, rgba(109,40,217,.08), rgba(15,118,110,.05));
  border-color: rgba(109,40,217,.14);
}

/* Charts cards */
.chart-card{
  background: rgba(255,255,255,.80);
  backdrop-filter: blur(10px);
}

/* Toast */
.toast.success{
  border-color: rgba(15,118,110,.35);
  background: rgba(15,118,110,.10);
}
.toast.error{
  border-color: rgba(180,35,24,.35);
  background: rgba(180,35,24,.10);
}

/* Small polish */
.muted{ color: var(--muted); }
a{ color: var(--brand); }

/* Reduce motion if user prefers */
@media (prefers-reduced-motion: reduce){
  .card, .btn, .step, input, textarea, select{
    transition: none !important;
  }
  .card:hover, .btn:hover, .step:hover{
    transform: none !important;
  }
}


.badge-v12{
  display:inline-block;
  vertical-align: middle;
  margin-left: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
  color: rgba(17,24,39,.92);
  border: 1px solid rgba(109,40,217,.20);
  background: linear-gradient(180deg, rgba(109,40,217,.18), rgba(31,78,140,.08));
}


.num-btn:focus{
  outline: none;
  box-shadow: 0 0 0 4px rgba(109,40,217,.20);
  background: rgba(255,255,255,.65);
}
.btn.mini{
  margin-left: 10px;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 999px;
}

/* improve touch on numbers (drag) */
.num-btn{
  touch-action: none; /* allow custom vertical scrub */
  -webkit-user-select: none;
  user-select: none;
}


/* v14: inline editable numbers (no popup, no scrub) */
.num-input{
  width: 120px;
  text-align: center;
  font-size: 34px;
  font-weight: 950;
  color: var(--text);
  border: 1px solid rgba(219,227,239,.95);
  background: rgba(255,255,255,.92);
  border-radius: 18px;
  padding: 10px 10px;
  box-shadow: 0 10px 18px rgba(17,24,39,.08);
}
.num-input:focus{
  outline: none;
  border-color: rgba(109,40,217,.35);
  box-shadow: 0 0 0 4px rgba(109,40,217,.20), 0 14px 22px rgba(17,24,39,.10);
}
@media (max-width: 420px){
  .num-input{ width: 96px; font-size: 30px; padding: 10px 8px; }
}


/* v15: App logo placements */
.app-logo{
  width: 28px;
  height: 28px;
  border-radius: 8px;
  margin-right: 10px;
  vertical-align: middle;
  box-shadow: 0 10px 18px rgba(17,24,39,.12);
}
.login-logo-wrap{
  display:flex;
  justify-content:center;
  margin-bottom: 12px;
}
.login-logo{
  width: 96px;
  height: 96px;
  border-radius: 22px;
  box-shadow: 0 18px 45px rgba(17,24,39,.16);
  border: 1px solid rgba(219,227,239,.95);
}

/* v16 logo sizing */
.app-logo{
  width:30px;
  height:30px;
}
.login-logo{
  width:110px;
  height:110px;
}

/* v18 logo polish */
.login-logo{
  border: none !important;
  background: transparent !important;
}

