/* ============================================================
   CheckTonTaf — style.css
   ============================================================ */

:root{
  --blue:#1656e8;
  --cyan:#15c5f0;
  --purple:#7b2ff7;
  --magenta:#d6189e;
  --orange:#ff7a30;

  --grad-brand: linear-gradient(135deg, var(--blue), var(--purple) 55%, var(--magenta) 80%, var(--orange));
  --grad-brand-soft: linear-gradient(135deg, rgba(22,86,232,.14), rgba(123,47,247,.14) 55%, rgba(214,24,158,.14) 80%, rgba(255,122,48,.14));

  --bg: #f5f6fb;
  --bg-elevated: #ffffff;
  --bg-soft: #eef0f8;
  --text: #161823;
  --text-muted: #5a5e72;
  --border: #e1e3ee;
  --danger: #d6285a;
  --danger-bg: #fdeaf0;
  --info: #1656e8;
  --info-bg: #eaf1ff;
  --success: #18a06a;
  --success-bg: #e8f8f1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 18px rgba(20,20,40,.06);
  --shadow-lg: 0 12px 36px rgba(20,20,40,.14);

  --font-scale: 1;
  --base-size: 16px;
  font-size: calc(var(--base-size) * var(--font-scale));
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0c0e16;
    --bg-elevated:#171a26;
    --bg-soft:#1d2130;
    --text:#eef0fb;
    --text-muted:#9ba0bb;
    --border:#2a2e42;
    --danger:#ff6b8f;
    --danger-bg:#3a1623;
    --info:#67a3ff;
    --info-bg:#152844;
    --success:#4fd6a4;
    --success-bg:#103626;
    --shadow: 0 4px 18px rgba(0,0,0,.35);
    --shadow-lg: 0 14px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"]{
  --bg:#0c0e16;
  --bg-elevated:#171a26;
  --bg-soft:#1d2130;
  --text:#eef0fb;
  --text-muted:#9ba0bb;
  --border:#2a2e42;
  --danger:#ff6b8f;
  --danger-bg:#3a1623;
  --info:#67a3ff;
  --info-bg:#152844;
  --success:#4fd6a4;
  --success-bg:#103626;
  --shadow: 0 4px 18px rgba(0,0,0,.35);
  --shadow-lg: 0 14px 40px rgba(0,0,0,.5);
}
:root[data-theme="light"]{
  --bg: #f5f6fb;
  --bg-elevated: #ffffff;
  --bg-soft: #eef0f8;
  --text: #161823;
  --text-muted: #5a5e72;
  --border: #e1e3ee;
}
:root[data-contrast="high"]{
  --border:#000;
  --text-muted: var(--text);
}
:root[data-theme="dark"][data-contrast="high"]{
  --border:#fff;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing:antialiased;
  transition:background .2s ease, color .2s ease;
}
[dir="rtl"] body{ font-family:'Inter', 'Tahoma', sans-serif; }

button, input, select, textarea{ font-family:inherit; font-size:1em; color:inherit; }
button{ cursor:pointer; }
a{ color:var(--blue); }

h1,h2,h3{ margin:0 0 .4em; line-height:1.2; }
p{ margin:0 0 .8em; color:var(--text-muted); }

.app-shell{
  max-width:560px;
  margin:0 auto;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  position:relative;
  padding-bottom:84px;
}

/* ---------- topbar ---------- */
.topbar{
  display:flex; align-items:center; gap:10px;
  padding:14px 16px;
  position:sticky; top:0; z-index:20;
  background:var(--bg);
  border-bottom:1px solid var(--border);
}
.topbar .brand{ display:flex; align-items:center; gap:10px; }
.topbar img.logo{ width:32px; height:32px; }
.topbar h1{ font-size:1.05rem; margin:0; }
.topbar .spacer{ flex:1; }
.icon-btn{
  background:var(--bg-soft); border:1px solid var(--border); border-radius:50%;
  width:38px; height:38px; display:flex; align-items:center; justify-content:center;
  font-size:1.1rem;
}
.back-btn{ background:none; border:none; font-size:1.3rem; padding:4px 8px; color:var(--text); }

/* ---------- views ---------- */
.view{ display:none; padding:16px; flex:1; animation:fadein .18s ease; }
.view.active{ display:block; }
@keyframes fadein{ from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:none;} }

/* ---------- nav bar ---------- */
.tabbar{
  position:fixed; bottom:0; left:0; right:0;
  display:flex; justify-content:center;
  background:var(--bg-elevated);
  border-top:1px solid var(--border);
  z-index:30;
  padding-bottom:env(safe-area-inset-bottom);
}
.tabbar-inner{ width:100%; max-width:560px; display:flex; }
.tab-btn{
  flex:1; background:none; border:none; padding:9px 4px 8px;
  display:flex; flex-direction:column; align-items:center; gap:3px;
  color:var(--text-muted); font-size:.68rem; position:relative;
}
.tab-btn .ic{ font-size:1.28rem; }
.tab-btn.active{ color:var(--blue); }
.tab-btn .badge{
  position:absolute; top:2px; right:calc(50% - 18px);
  background:var(--danger); color:#fff; border-radius:10px;
  font-size:.6rem; min-width:16px; height:16px; line-height:16px; text-align:center; padding:0 3px;
}

/* ---------- cards ---------- */
.card{
  background:var(--bg-elevated); border:1px solid var(--border);
  border-radius:var(--radius); padding:16px; margin-bottom:14px;
  box-shadow:var(--shadow);
}
.card.gradient{
  background:var(--grad-brand-soft);
  border:1px solid var(--border);
}
.section-title{
  font-size:.78rem; text-transform:uppercase; letter-spacing:.05em;
  color:var(--text-muted); font-weight:700; margin:22px 0 8px;
}
.section-title:first-child{ margin-top:0; }

/* ---------- buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius:999px; padding:12px 20px; font-weight:600; border:1px solid transparent;
  width:100%;
}
.btn-primary{ background:var(--grad-brand); color:#fff; box-shadow:var(--shadow); }
.btn-secondary{ background:var(--bg-soft); color:var(--text); border-color:var(--border); }
.btn-outline{ background:transparent; color:var(--text); border-color:var(--border); }
.btn-danger{ background:var(--danger-bg); color:var(--danger); border-color:transparent; }
.btn-sm{ padding:8px 14px; font-size:.85em; width:auto; }
.btn-block-row{ display:flex; gap:10px; }
.btn:disabled{ opacity:.5; }

/* ---------- forms ---------- */
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:.82rem; font-weight:600; margin-bottom:5px; color:var(--text-muted); }
.field input[type=text], .field input[type=number], .field input[type=time],
.field input[type=date], .field select, .field textarea{
  width:100%; padding:11px 12px; border-radius:var(--radius-sm);
  border:1px solid var(--border); background:var(--bg-soft); color:var(--text);
}
.field textarea{ resize:vertical; min-height:60px; }
.field .hint{ font-size:.74rem; color:var(--text-muted); margin-top:4px; }
.field-row{ display:flex; gap:10px; }
.field-row .field{ flex:1; }
.checkbox-row{ display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.checkbox-row input{ width:20px; height:20px; }
.switch-row{ display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--border); }
.switch-row:last-child{ border-bottom:none; }
.switch{ position:relative; width:46px; height:26px; flex:none; }
.switch input{ opacity:0; width:0; height:0; }
.switch .slider{ position:absolute; inset:0; background:var(--border); border-radius:999px; transition:.2s; }
.switch .slider:before{ content:''; position:absolute; width:20px; height:20px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; }
.switch input:checked + .slider{ background:var(--grad-brand); }
.switch input:checked + .slider:before{ transform:translateX(20px); }

/* segmented control */
.segmented{ display:flex; background:var(--bg-soft); border-radius:999px; padding:3px; border:1px solid var(--border); }
.segmented button{ flex:1; background:none; border:none; padding:8px 6px; border-radius:999px; font-size:.82rem; color:var(--text-muted); font-weight:600; }
.segmented button.active{ background:var(--bg-elevated); color:var(--text); box-shadow:var(--shadow); }

/* ---------- list items ---------- */
.list-item{
  display:flex; align-items:center; gap:12px; padding:13px 14px;
  background:var(--bg-elevated); border:1px solid var(--border); border-radius:var(--radius-sm);
  margin-bottom:8px;
}
.list-item .meta{ flex:1; min-width:0; }
.list-item .meta .title{ font-weight:600; }
.list-item .meta .sub{ font-size:.8rem; color:var(--text-muted); }
.list-item .chevron{ color:var(--text-muted); }

/* day segment editor */
.segment-row{
  display:flex; align-items:center; gap:8px; padding:10px; border-radius:var(--radius-sm);
  background:var(--bg-soft); margin-bottom:8px; border:1px solid var(--border);
}
.segment-row select{ flex:none; width:auto; padding:8px; }
.segment-row input[type=time]{ width:auto; flex:1; padding:8px; }
.segment-row .rm{ background:none; border:none; color:var(--danger); font-size:1.1rem; padding:4px 6px; }
.segment-dot{ width:10px; height:10px; border-radius:50%; flex:none; }
.segment-dot.travail{ background:var(--blue); }
.segment-dot.pause{ background:var(--orange); }

/* notification card */
.notif-card{ border-left:4px solid var(--danger); }
.notif-card.info{ border-left-color:var(--info); }
.notif-card .tag{
  display:inline-block; font-size:.7rem; font-weight:700; padding:2px 9px; border-radius:999px;
  background:var(--danger-bg); color:var(--danger); margin-bottom:8px;
}
.notif-card.info .tag{ background:var(--info-bg); color:var(--info); }
.notif-card .msg{ color:var(--text); margin-bottom:10px; }
.notif-card dl{ display:grid; grid-template-columns:auto 1fr; gap:3px 10px; font-size:.8rem; color:var(--text-muted); margin:0 0 10px; }
.notif-card dt{ font-weight:600; }
.notif-card dd{ margin:0; }

/* stat tiles */
.stat-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.stat-tile{ background:var(--bg-elevated); border:1px solid var(--border); border-radius:var(--radius-sm); padding:12px; }
.stat-tile .num{ font-size:1.35rem; font-weight:800; }
.stat-tile .lbl{ font-size:.74rem; color:var(--text-muted); }
.stat-tile.warn .num{ color:var(--danger); }
.stat-tile.ok .num{ color:var(--success); }

/* empty state */
.empty-state{ text-align:center; padding:40px 14px; color:var(--text-muted); }
.empty-state .ic{ font-size:2.4rem; margin-bottom:10px; }

/* modal / sheet */
.sheet-overlay{
  position:fixed; inset:0; background:rgba(10,12,20,.5); z-index:50;
  display:flex; align-items:flex-end; justify-content:center;
  opacity:0; pointer-events:none; transition:opacity .2s ease;
}
.sheet-overlay.open{ opacity:1; pointer-events:auto; }
.sheet{
  width:100%; max-width:560px; background:var(--bg-elevated);
  border-radius:20px 20px 0 0; padding:18px 16px calc(20px + env(safe-area-inset-bottom));
  max-height:88vh; overflow-y:auto;
  transform:translateY(16px); transition:transform .2s ease;
}
.sheet-overlay.open .sheet{ transform:none; }
.sheet-handle{ width:38px; height:4px; background:var(--border); border-radius:99px; margin:0 auto 14px; }

.toast{
  position:fixed; bottom:96px; left:50%; transform:translateX(-50%);
  background:var(--text); color:var(--bg); padding:10px 18px; border-radius:999px;
  font-size:.85rem; z-index:80; box-shadow:var(--shadow-lg); opacity:0; pointer-events:none;
  transition:opacity .2s ease, transform .2s ease;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(-6px); }

.divider{ height:1px; background:var(--border); margin:18px 0; }

.banner{ display:flex; gap:10px; align-items:flex-start; background:var(--info-bg); color:var(--info); border-radius:var(--radius-sm); padding:12px; font-size:.84rem; margin-bottom:14px; }
.banner.warn{ background:var(--danger-bg); color:var(--danger); }

.onboard-screen{ display:flex; flex-direction:column; min-height:100vh; padding:24px 20px; }
.onboard-screen .grow{ flex:1; display:flex; flex-direction:column; justify-content:center; align-items:center; text-align:center; }
.onboard-screen img.logo-big{ width:120px; margin-bottom:18px; }
.dots{ display:flex; gap:6px; justify-content:center; margin:18px 0; }
.dots span{ width:7px; height:7px; border-radius:50%; background:var(--border); }
.dots span.active{ background:var(--blue); width:18px; border-radius:4px; }

.preset-option{
  display:flex; align-items:center; gap:12px; padding:14px; border:1px solid var(--border);
  border-radius:var(--radius-sm); margin-bottom:10px; background:var(--bg-elevated);
}
.preset-option input{ width:20px; height:20px; }
.preset-option .label{ font-weight:600; }

.donation-card{ background:var(--grad-brand); color:#fff; border-radius:var(--radius); padding:18px; margin-bottom:14px; }
.donation-card a.btn{ background:#fff; color:var(--blue); margin-top:10px; }

footer.legal{ text-align:center; padding:18px; font-size:.72rem; color:var(--text-muted); }

::selection{ background:var(--purple); color:#fff; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:0.001ms !important; transition-duration:0.001ms !important; }
}
