/* PSX Sharia Alerts web app. Mobile-first; light and dark mode follow the phone's setting. */
:root {
  --green: #0f5132;
  --green-2: #198754;
  --gold: #d4a017;
  --bg: #f3f6f4;
  --card: #ffffff;
  --text: #17231d;
  --muted: #5d6b63;
  --line: #dde5e0;
  --soft: #e8f3ec;
  --red: #b42318;
  --red-soft: #fdecea;
  --warn-soft: #fff6db;
  --tabbar-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1411;
    --card: #16201b;
    --text: #e7efe9;
    --muted: #9aaba1;
    --line: #26332c;
    --soft: #173326;
    --red: #ff8a80;
    --red-soft: #3a1d1b;
    --warn-soft: #3a3115;
    --green-2: #2fb36f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--green-2); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--green); color: #fff;
}
.topbar-logo { width: 30px; height: 30px; border-radius: 8px; }
.topbar-title { font-weight: 700; font-size: 18px; flex: 1; }
.beta { font-size: 11px; font-weight: 700; letter-spacing: .5px; background: var(--gold); color: #1d1600; padding: 2px 7px; border-radius: 99px; }

/* ---------- layout ---------- */
.page { max-width: 640px; margin: 0 auto; padding: 14px 14px 0; }
.page.narrow { max-width: 460px; padding-top: 40px; }
h1 { font-size: 22px; margin: 4px 0 10px; }
h2 { font-size: 19px; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin-bottom: 14px;
}
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.pre { white-space: pre-line; overflow-wrap: anywhere; margin: 0; }
.logo { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 10px; }
.step { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.welcome p { margin: 10px 0; }
.features { list-style: none; display: inline-block; text-align: left; padding: 0; margin: 4px 0; }
.features li { margin: 6px 0; }
.disclaimer { font-size: 13px; color: var(--muted); padding: 4px 4px 14px; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; margin: 8px 0 0; padding: 12px 16px;
  font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  color: var(--text); background: var(--soft); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green-2); color: #fff; border-color: transparent; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.big { min-height: 58px; font-size: 18px; }
.btn.left { justify-content: flex-start; text-align: left; }
.btn[disabled] { opacity: .6; }
.btn .sub { display: block; font-weight: 400; font-size: 14px; color: var(--muted); }
.btn.primary .sub { color: #e6f4ec; }
.row { display: flex; gap: 8px; }
.row > .btn { flex: 1; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid .btn { margin: 0; min-height: 76px; flex-direction: column; gap: 2px; font-size: 15px; }
.grid .btn .emoji { font-size: 24px; }

/* ---------- lists ---------- */
.stock {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 10px 14px; margin-top: 8px;
  font: inherit; color: var(--text); text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
}
.stock b { display: block; }
.stock .name { font-size: 14px; color: var(--muted); }
.stock .px { white-space: nowrap; font-weight: 600; }
.up { color: var(--green-2); }
.down { color: var(--red); }
.alert-item { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.alert-item:first-of-type { border-top: 0; margin-top: 4px; padding-top: 0; }
.alert-item .btn { min-height: 46px; font-size: 15px; }
.market { white-space: pre-line; }
.market b { font-size: 18px; }

/* ---------- forms ---------- */
input[type=text], input[type=search], select {
  width: 100%; min-height: 54px; padding: 12px 14px; margin-top: 8px;
  font: inherit; font-size: 20px; color: var(--text);
  background: var(--bg); border: 2px solid var(--line); border-radius: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--green-2); }
select { font-size: 17px; }
.error { background: var(--red-soft); color: var(--red); border-radius: 12px; padding: 10px 12px; margin-top: 10px; white-space: pre-line; }
.warning { background: var(--warn-soft); border-radius: 12px; padding: 12px; margin-top: 10px; white-space: pre-line; }
.success { background: var(--soft); border-radius: 12px; padding: 12px; white-space: pre-line; }
.switch {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 12px 14px; margin-top: 10px;
  font: inherit; color: var(--text); text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
}
.pill { font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.pill.on { background: var(--green-2); color: #fff; }
.pill.off { background: var(--line); color: var(--muted); }
.status { font-size: 18px; font-weight: 700; padding: 12px; border-radius: 12px; text-align: center; }
.status.on { background: var(--soft); color: var(--green-2); }
.status.off { background: var(--warn-soft); }
ol.steps { padding-left: 22px; margin: 8px 0; }
ol.steps li { margin: 8px 0; }
.banner { display: block; text-decoration: none; color: var(--text); background: var(--warn-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; }

/* ---------- bottom navigation ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabbar .tab-icon { font-size: 22px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabbar a.active { color: var(--green-2); }
.tabbar a.active .tab-icon { filter: none; opacity: 1; }

.toast {
  position: fixed; left: 16px; right: 16px; z-index: 20;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  max-width: 600px; margin: 0 auto; padding: 12px 16px;
  background: #1f2a24; color: #fff; border-radius: 14px; white-space: pre-line;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
