/* ============================================================
   Isola mobile redesign — DESIGN SYSTEM (preview only)
   Primary  : #007bff (blue)
   Accent   : #fd7e14 (orange)
   + full tonal scales, grayscale, semantic & elevation tokens
   ============================================================ */
:root {
  /* ---------- Primary · Blue ---------- */
  --primary-50:#e6f2ff;  --primary-100:#cce4ff; --primary-200:#99c9ff;
  --primary-300:#66adff; --primary-400:#3392ff; --primary-500:#007bff;
  --primary-600:#0062cc; --primary-700:#004a99; --primary-800:#003166; --primary-900:#001f44;

  /* ---------- Accent · Orange ---------- */
  --accent-50:#fff3e9;  --accent-100:#ffe3cc; --accent-200:#fec79a;
  --accent-300:#feab67; --accent-400:#fd8f35; --accent-500:#fd7e14;
  --accent-600:#e36a05; --accent-700:#b35304; --accent-800:#823c03; --accent-900:#522602;

  /* ---------- Grayscale ---------- */
  --gray-0:#ffffff;  --gray-50:#f7f9fc; --gray-100:#eef1f6; --gray-200:#e3e8ef;
  --gray-300:#d2d9e3; --gray-400:#b6bfcc; --gray-500:#8893a3; --gray-600:#5d6776;
  --gray-700:#3d4654; --gray-800:#252c39; --gray-900:#141922;

  /* ---------- Semantic ---------- */
  --success:#1a9e4b; --success-l:#e6f6ec;
  --danger:#e5484d;  --danger-l:#fdecec;
  --warning:#f59e0b; --warning-l:#fef3e0;

  /* ---------- Elevation / depth ---------- */
  --shadow-sm:0 1px 2px rgba(16,30,54,.06), 0 1px 1px rgba(16,30,54,.04);
  --shadow-md:0 4px 14px rgba(16,30,54,.08), 0 2px 4px rgba(16,30,54,.05);
  --shadow-lg:0 16px 36px rgba(16,30,54,.14), 0 6px 12px rgba(16,30,54,.08);
  --shadow-primary:0 8px 20px rgba(0,123,255,.28);
  --shadow-danger:0 8px 20px rgba(229,72,77,.28);

  /* ---------- Semantic roles (mapped to scales) ---------- */
  --bg:var(--gray-50);  --card:var(--gray-0); --text:var(--gray-900);
  --muted:var(--gray-600); --border:var(--gray-200); --nav-off:var(--gray-500);
  --dark:var(--primary-900);

  /* legacy aliases kept so existing markup recolors automatically */
  --gold:var(--primary-500);  --gold-d:var(--primary-600); --gold-l:var(--primary-50);
  --amber:var(--accent-600);  --amber-l:var(--accent-50);
  --red:var(--danger);        --red-l:var(--danger-l);

  /* ---------- Gradients & surfaces ---------- */
  --app-grad:linear-gradient(180deg, rgba(0,123,255,.11) 0%, rgba(0,123,255,0) 320px);
  --surface-grad:linear-gradient(158deg, #ffffff 0%, #eff6ff 100%);
  --tile-grad:linear-gradient(160deg, #ffffff 0%, #e9f3ff 100%);
  --accent-bar:linear-gradient(180deg, var(--primary-400), var(--primary-700));
  --grad-primary:linear-gradient(135deg, var(--primary-400), var(--primary-600));
  --grad-danger:linear-gradient(135deg, #ff5b60, var(--danger));
  --grad-accent:linear-gradient(135deg, var(--accent-400), var(--accent-600));

  /* ---------- Depth: glass + layered shadows + inner highlight ---------- */
  --glass:rgba(255,255,255,.72); --glass-border:rgba(255,255,255,.55);
  --inset-hi:inset 0 1px 0 rgba(255,255,255,.75);
  --shadow-tile:0 6px 16px rgba(0,60,130,.10), 0 2px 5px rgba(16,30,54,.06);
  --shadow-card:0 10px 24px rgba(16,30,54,.09), 0 3px 8px rgba(16,30,54,.05);
  --shadow-pop:0 18px 40px rgba(0,60,130,.16), 0 6px 14px rgba(16,30,54,.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:#0d1117; --card:#161c25; --text:#e7edf4;
    --muted:#9aa6b6; --border:#26303c; --nav-off:#697482; --dark:#071427;

    --gold:var(--primary-400); --gold-d:var(--primary-300); --gold-l:#0f2742;
    --amber:var(--accent-400); --amber-l:#2c1d0e;
    --red:#f0676b; --red-l:#2c1719;
    --success-l:#10241a; --warning-l:#2a2110;

    --shadow-sm:0 1px 2px rgba(0,0,0,.45);
    --shadow-md:0 4px 14px rgba(0,0,0,.5);
    --shadow-lg:0 16px 36px rgba(0,0,0,.55);
    --shadow-primary:0 8px 20px rgba(0,123,255,.35);
    --shadow-danger:0 8px 20px rgba(229,72,77,.32);

    --app-grad:linear-gradient(180deg, rgba(51,146,255,.16) 0%, rgba(51,146,255,0) 320px);
    --surface-grad:linear-gradient(158deg, #1b2330 0%, #141b25 100%);
    --tile-grad:linear-gradient(160deg, #1d2735 0%, #141b25 100%);

    --glass:rgba(18,24,33,.72); --glass-border:rgba(255,255,255,.07);
    --inset-hi:inset 0 1px 0 rgba(255,255,255,.06);
    --shadow-tile:0 6px 16px rgba(0,0,0,.5), 0 2px 5px rgba(0,0,0,.4);
    --shadow-card:0 10px 24px rgba(0,0,0,.5), 0 3px 8px rgba(0,0,0,.4);
    --shadow-pop:0 18px 40px rgba(0,0,0,.6), 0 6px 14px rgba(0,0,0,.45);
  }
}

* { box-sizing:border-box; margin:0; padding:0; }
body { font-family:'Cairo', system-ui, sans-serif; background:var(--bg); color:var(--text); }
a { text-decoration:none; color:inherit; }
.app { max-width:440px; margin:0 auto; min-height:100vh; background:var(--bg); background-image:var(--app-grad); background-repeat:no-repeat; padding-bottom:80px; position:relative; }

.statusbar { display:flex; justify-content:space-between; font-size:12px; color:var(--muted); padding:12px 20px 0; }
.statusbar .icons { display:flex; gap:7px; }

.home-head { padding:12px 20px 4px; display:flex; align-items:flex-start; justify-content:space-between; }
.home-head .hi { font-size:25px; font-weight:800; color:var(--text); line-height:1.2; }
.home-head .unit { font-size:13px; font-weight:600; color:var(--muted); margin-top:2px; }

.appbar { padding:8px 16px 14px; display:flex; align-items:center; gap:12px; border-bottom:1px solid var(--glass-border); background:var(--glass); backdrop-filter:saturate(180%) blur(16px); -webkit-backdrop-filter:saturate(180%) blur(16px); box-shadow:var(--shadow-md); position:sticky; top:0; z-index:20; }
.appbar .title { font-size:19px; font-weight:800; color:var(--text); }

.iconbtn { width:44px; height:44px; border-radius:14px; background:var(--card); border:1px solid var(--border); display:flex; align-items:center; justify-content:center; color:var(--text); font-size:22px; position:relative; flex-shrink:0; box-shadow:var(--shadow-sm); }
.badge { position:absolute; top:-5px; left:-5px; background:var(--accent-500); color:#fff; font-size:11px; font-weight:700; min-width:19px; height:19px; border-radius:10px; display:flex; align-items:center; justify-content:center; padding:0 4px; box-shadow:0 2px 6px rgba(253,126,20,.4); }

.body { padding:16px; }
.section-row { display:flex; align-items:center; justify-content:space-between; margin:28px 2px 14px; }
.section-row.first { margin-top:8px; }
.section-title { font-size:17px; font-weight:800; color:var(--text); display:inline-flex; align-items:center; gap:9px; }
.section-title::before { content:''; width:4px; height:18px; border-radius:3px; background:var(--accent-bar); flex-shrink:0; }
.section-title.sm { font-size:14px; }
.section-title.sm::before { height:14px; }
.section-link { font-size:12px; font-weight:700; color:var(--primary-600); }

.grid { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
.tile { background:var(--tile-grad); border:1px solid var(--border); border-radius:18px; padding:14px 4px 11px; text-align:center; box-shadow:var(--shadow-tile), var(--inset-hi); transition:transform .14s ease, box-shadow .14s ease; }
.tile:active { transform:translateY(2px); box-shadow:var(--shadow-sm), var(--inset-hi); }
.tile i { font-size:27px; color:var(--primary-600); }
.tile span { display:block; font-size:11.5px; font-weight:600; color:var(--text); margin-top:7px; }

.chip { width:42px; height:42px; border-radius:13px; display:flex; align-items:center; justify-content:center; font-size:22px; flex-shrink:0; box-shadow:var(--shadow-sm), var(--inset-hi); }
.chip-gold { background:var(--gold-l); color:var(--gold-d); }
.chip-amber { background:var(--amber-l); color:var(--amber); }

.card { background:var(--surface-grad); border:1px solid var(--border); border-radius:16px; padding:13px 14px; display:flex; align-items:center; gap:12px; margin-bottom:12px; box-shadow:var(--shadow-card), var(--inset-hi); }
.card .meta { flex:1; line-height:1.45; }
.card .meta .t { font-size:13.5px; font-weight:600; color:var(--text); }
.card .meta .s { font-size:12px; color:var(--muted); }

.pill { font-size:11px; font-weight:700; padding:3px 10px; border-radius:20px; white-space:nowrap; }
.pill-gold { color:var(--gold-d); background:var(--gold-l); }
.pill-amber { color:var(--amber); background:var(--amber-l); }

.hero { margin-top:4px; border-radius:20px; background:linear-gradient(135deg, var(--primary-700), var(--primary-900)); padding:22px 20px 20px; box-shadow:var(--shadow-primary); }
.hero .brand { font-size:11px; letter-spacing:2px; color:var(--accent-400); font-weight:700; }
.hero .h { font-size:21px; font-weight:800; color:#fff; margin-top:6px; line-height:1.3; }
.hero .s { font-size:13px; color:#bcd4f0; margin-top:3px; }
.hero .cta { display:inline-flex; align-items:center; gap:6px; margin-top:14px; background:var(--accent-500); color:#fff; font-size:13px; font-weight:700; padding:8px 16px; border-radius:22px; }

.btn { width:100%; border:none; border-radius:16px; padding:15px; font-family:inherit; font-size:16px; font-weight:700; display:flex; align-items:center; justify-content:center; gap:9px; cursor:pointer; }
.btn-danger { background:var(--grad-danger); color:#fff; box-shadow:var(--shadow-danger); }
.btn-primary { background:var(--grad-primary); color:#fff; box-shadow:var(--shadow-primary); }
.btn-accent { background:var(--grad-accent); color:#fff; box-shadow:0 8px 20px rgba(253,126,20,.28); }
.btn-ghost { background:transparent; color:var(--danger); border:1.5px solid var(--danger-l); }

.bottom-nav { position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:440px; display:flex; background:var(--glass); backdrop-filter:saturate(180%) blur(18px); -webkit-backdrop-filter:saturate(180%) blur(18px); border-top:1px solid var(--glass-border); box-shadow:0 -8px 24px rgba(16,30,54,.1); }
.bottom-nav a { flex:1; text-align:center; padding:10px 0 12px; color:var(--nav-off); position:relative; }
.bottom-nav a.active { color:var(--primary-600); }
.bottom-nav a i { font-size:24px; }
.bottom-nav a span { display:block; font-size:11px; margin-top:2px; }
.bottom-nav a.active span { font-weight:700; }
.bottom-nav .nbadge { position:absolute; top:7px; left:calc(50% - 20px); background:var(--accent-500); color:#fff; font-size:10px; font-weight:700; min-width:16px; height:16px; border-radius:8px; display:flex; align-items:center; justify-content:center; padding:0 3px; }
.bottom-nav a .navava { width:26px; height:26px; border-radius:50%; object-fit:cover; border:1.5px solid currentColor; display:block; margin:0 auto; }

/* ============================================================
   v2 COMPONENTS — lists, switches, tabs, forms, SOS, modals
   ============================================================ */

/* List rows (settings, menus) */
.list { background:var(--surface-grad); border:1px solid var(--border); border-radius:18px; box-shadow:var(--shadow-card), var(--inset-hi); overflow:hidden; }
.list .row { display:flex; align-items:center; gap:14px; padding:14px 16px; border-bottom:1px solid var(--border); }
.list .row:last-child { border-bottom:none; }
.list .row .ic { width:38px; height:38px; border-radius:11px; background:var(--gold-l); color:var(--gold-d); display:flex; align-items:center; justify-content:center; font-size:20px; flex-shrink:0; }
.list .row .ic.accent { background:var(--amber-l); color:var(--amber); }
.list .row .ic.danger { background:var(--danger-l); color:var(--danger); }
.list .row .ic.success { background:var(--success-l); color:var(--success); }
.list .row .txt { flex:1; min-width:0; }
.list .row .txt .t { font-size:14px; font-weight:700; color:var(--text); }
.list .row .txt .s { font-size:12px; color:var(--muted); margin-top:1px; }
.list .row .chev { color:var(--nav-off); font-size:18px; flex-shrink:0; }
.list-label { font-size:12px; font-weight:700; color:var(--muted); margin:22px 4px 9px; }

/* Toggle switch */
.switch { position:relative; width:46px; height:28px; flex-shrink:0; display:inline-block; }
.switch input { display:none; }
.switch .slider { position:absolute; inset:0; background:var(--gray-300); border-radius:20px; transition:.2s; cursor:pointer; }
.switch .slider::before { content:''; position:absolute; width:22px; height:22px; border-radius:50%; background:#fff; top:3px; right:3px; transition:.2s; box-shadow:0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background:var(--primary-500); }
.switch input:checked + .slider::before { transform:translateX(-18px); }

/* Segmented tabs */
.segmented { display:flex; background:var(--gray-100); border-radius:14px; padding:4px; gap:4px; margin-bottom:4px; }
.segmented a { flex:1; text-align:center; padding:9px 6px; border-radius:11px; font-size:13px; font-weight:700; color:var(--muted); }
.segmented a.active { background:var(--card); color:var(--primary-600); box-shadow:var(--shadow-sm); }

/* Form fields */
.field { margin-bottom:15px; }
.field label { display:block; font-size:13px; font-weight:700; margin-bottom:7px; color:var(--text); }
.field .control { width:100%; background:var(--card); border:1px solid var(--border); border-radius:13px; padding:13px 14px; font-family:inherit; font-size:14px; color:var(--text); box-shadow:var(--inset-hi); }
.field .control:focus { outline:none; border-color:var(--primary-400); box-shadow:0 0 0 3px var(--primary-50); }
.field textarea.control { min-height:96px; resize:vertical; }
.field .control::placeholder { color:var(--nav-off); }

/* Choice chips */
.choice-row { display:flex; gap:9px; flex-wrap:wrap; }
.choice { padding:9px 14px; border-radius:12px; border:1px solid var(--border); background:var(--card); font-size:13px; font-weight:700; color:var(--muted); display:inline-flex; align-items:center; gap:6px; cursor:pointer; }
.choice.active { border-color:var(--primary-500); background:var(--primary-50); color:var(--primary-700); }

/* Floating action button (full-width docked) */
.fab { position:fixed; bottom:92px; left:50%; transform:translateX(-50%); width:calc(100% - 32px); max-width:408px; z-index:15; }

/* Toast */
.toast { position:fixed; bottom:104px; left:50%; transform:translateX(-50%); background:var(--gray-900); color:#fff; padding:12px 20px; border-radius:14px; font-size:13px; font-weight:700; box-shadow:var(--shadow-lg); opacity:0; transition:opacity .25s, transform .25s; z-index:50; pointer-events:none; white-space:nowrap; }
.toast.show { opacity:1; transform:translateX(-50%) translateY(-4px); }

/* SOS hold-to-activate */
.sos-card { background:var(--surface-grad); border:1px solid var(--border); border-radius:20px; box-shadow:var(--shadow-card), var(--inset-hi); padding:18px 16px 20px; display:flex; flex-direction:column; align-items:center; gap:10px; }
.sos-hold { position:relative; width:150px; height:150px; -webkit-tap-highlight-color:transparent; cursor:pointer; user-select:none; touch-action:none; }
.sos-hold svg { transform:rotate(-90deg); display:block; }
.sos-hold .track { stroke:var(--danger-l); }
.sos-hold .prog { stroke:var(--danger); stroke-linecap:round; transition:stroke-dashoffset .08s linear; }
.sos-hold .core { position:absolute; inset:17px; border-radius:50%; background:var(--grad-danger); box-shadow:var(--shadow-danger), inset 0 2px 0 rgba(255,255,255,.35); display:flex; flex-direction:column; align-items:center; justify-content:center; color:#fff; transition:transform .1s; }
.sos-hold.holding .core { transform:scale(.95); }
.sos-hold .core .lbl { font-size:30px; font-weight:900; letter-spacing:3px; line-height:1; }
.sos-hold .core .hint { font-size:10px; font-weight:700; opacity:.92; margin-top:3px; }
.sos-cap { font-size:12.5px; color:var(--muted); font-weight:600; text-align:center; }
.sos-cap b { color:var(--danger); }

/* SOS floating button (corner) */
.sos-fab { position:fixed; bottom:110px; left:18px; z-index:30; width:58px; height:58px; -webkit-tap-highlight-color:transparent; user-select:none; touch-action:none; cursor:pointer; transform-origin:0% 100%; transition:transform .28s cubic-bezier(.2,.8,.3,1.5); }
.sos-fab::before { content:''; position:absolute; inset:0; border-radius:50%; background:var(--danger); opacity:.4; z-index:-1; animation:sosPulse 2.2s ease-out infinite; }
@keyframes sosPulse { 0%{transform:scale(1);opacity:.4;} 70%{transform:scale(1.9);opacity:0;} 100%{opacity:0;} }
.sos-fab svg { position:absolute; inset:0; transform:rotate(-90deg); }
.sos-fab .track { stroke:rgba(255,255,255,.35); }
.sos-fab .prog { stroke:#fff; stroke-linecap:round; transition:stroke-dashoffset .08s linear; }
.sos-fab .core { position:absolute; inset:0; border-radius:50%; background:var(--grad-danger); box-shadow:var(--shadow-danger), inset 0 2px 0 rgba(255,255,255,.35); display:flex; align-items:center; justify-content:center; color:#fff; font-weight:900; font-size:17px; letter-spacing:1px; }
.sos-fab.holding { transform:scale(2); }
.sos-fab.holding::before { animation:none; }
.sos-fab.holding .core { font-size:22px; }

/* Modal / sheet */
.scrim { position:fixed; inset:0; background:rgba(10,18,30,.5); backdrop-filter:blur(3px); display:none; align-items:flex-end; justify-content:center; z-index:40; }
.scrim.open { display:flex; }
.sheet { width:100%; max-width:440px; background:var(--bg); border-radius:24px 24px 0 0; padding:8px 18px 26px; box-shadow:0 -10px 40px rgba(0,0,0,.25); max-height:88vh; overflow:auto; }
.sheet .grab { width:42px; height:5px; border-radius:3px; background:var(--gray-300); margin:6px auto 14px; }
.sheet h3 { font-size:18px; font-weight:800; margin-bottom:16px; }

/* Empty state */
.empty { text-align:center; padding:48px 20px; color:var(--muted); }
.empty i { font-size:46px; color:var(--gray-300); }
.empty p { font-size:14px; margin-top:10px; }

/* ===== Shared: stats, charts, tables (all roles) ===== */
.statgrid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.statgrid.two { grid-template-columns:repeat(2,1fr); }
.statcard { background:var(--surface-grad); border:1px solid var(--border); border-radius:16px; padding:14px 10px; text-align:center; box-shadow:var(--shadow-tile), var(--inset-hi); }
.statcard .ic { font-size:20px; margin-bottom:5px; color:var(--primary-600); }
.statcard .n { font-size:21px; font-weight:900; color:var(--text); line-height:1.1; }
.statcard .l { font-size:11px; color:var(--muted); margin-top:3px; }
.statcard.primary .n, .statcard.primary .ic { color:var(--primary-600); }
.statcard.accent .n, .statcard.accent .ic { color:var(--accent-600); }
.statcard.danger .n, .statcard.danger .ic { color:var(--danger); }
.statcard.success .n, .statcard.success .ic { color:var(--success); }

.barchart { display:flex; flex-direction:column; gap:13px; }
.barchart .b .top { display:flex; justify-content:space-between; font-size:12.5px; font-weight:600; margin-bottom:6px; }
.barchart .b .top .v { color:var(--muted); font-weight:700; }
.barchart .b .track { height:10px; border-radius:6px; background:rgba(128,140,160,.18); overflow:hidden; }
.barchart .b .fill { height:100%; border-radius:6px; background:var(--grad-primary); }
.barchart .b .fill.accent { background:var(--grad-accent); }
.barchart .b .fill.danger { background:var(--grad-danger); }
.barchart .b .fill.success { background:linear-gradient(135deg,#34d399,#0e9f6e); }

.card-pad { background:var(--surface-grad); border:1px solid var(--border); border-radius:18px; box-shadow:var(--shadow-card), var(--inset-hi); padding:16px; }

.tbl-wrap { background:var(--surface-grad); border:1px solid var(--border); border-radius:16px; box-shadow:var(--shadow-card), var(--inset-hi); overflow:auto; padding:2px 12px; }
.tbl { width:100%; border-collapse:collapse; font-size:12.5px; white-space:nowrap; }
.tbl th { text-align:right; color:var(--muted); font-weight:700; padding:11px 8px; border-bottom:1px solid var(--border); font-size:11.5px; }
.tbl td { text-align:right; padding:12px 8px; border-bottom:1px solid var(--border); color:var(--text); }
.tbl tr:last-child td { border-bottom:none; }

/* Month / period selector */
.period { display:flex; align-items:center; justify-content:center; gap:14px; background:var(--surface-grad); border:1px solid var(--border); border-radius:14px; padding:11px; box-shadow:var(--inset-hi); }
.period b { font-size:15px; font-weight:800; }
.period a { color:var(--primary-600); font-size:22px; }
