:root {
    --blue: #0012FF; --blue-dk: #0010cc;
    --ink: #0F172A; --muted: #64748B; --bd: #E2E8F0;
    --bg: #F1F5F9; --bg2: #EEF1FF;
    --surface: #FFFFFF; --surface-2: #F8FAFC;
    --ok: #059669; --err: #DC2626;
    --ok-bg: #ECFDF5; --err-bg: #FEF2F2;
    --blue-tint: #EEF1FF;
    --shadow: rgba(15, 23, 42, .12);
}
html[data-theme="dark"] {
    --blue: #4460FF; --blue-dk: #3550ee;
    --ink: #E7ECF5; --muted: #93A2BE; --bd: #2A3350;
    --bg: #0B1020; --bg2: #0E1530;
    --surface: #151B2E; --surface-2: #1C2338;
    --ok: #34D399; --err: #F87171;
    --ok-bg: rgba(52, 211, 153, .13); --err-bg: rgba(248, 113, 113, .13);
    --blue-tint: rgba(68, 96, 255, .15);
    --shadow: rgba(0, 0, 0, .45);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, 'IBM Plex Sans Arabic', system-ui, sans-serif;
    background: linear-gradient(160deg, var(--bg2) 0%, var(--bg) 100%);
    color: var(--ink);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    transition: background .25s, color .25s;
}
.wrap { width: 100%; max-width: 460px; }
.card { background: var(--surface); border: 1px solid var(--bd); border-radius: 18px; padding: 36px 30px; box-shadow: 0 20px 60px var(--shadow); }
.brand { text-align: center; margin-bottom: 24px; }
.view h1 { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.view .sub { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.field input {
    width: 100%; padding: 13px 15px; border: 1px solid var(--bd); border-radius: 10px;
    font-family: inherit; font-size: 15px; background: var(--surface-2); color: var(--ink); transition: .15s;
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); background: var(--surface); }
.field input[dir=ltr] { direction: ltr; text-align: left; }
.btn { width: 100%; padding: 14px; background: var(--blue); color: #fff; border: none; border-radius: 10px; font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: .2s; margin-top: 6px; }
.btn:hover { background: var(--blue-dk); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.msg { font-size: 13px; font-weight: 600; padding: 11px 14px; border-radius: 9px; margin-bottom: 16px; }
.msg.err { background: var(--err-bg); color: var(--err); border: 1px solid var(--err); }
.msg.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.foot { text-align: center; font-size: 11px; color: var(--muted); margin-top: 18px; }
.foot a { color: inherit; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

/* Auth view switcher (login ⇄ signup) */
.auth-alt { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-alt .link-btn { color: var(--blue); }

/* Dashboard */
.dash-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dash-top h1 { font-size: 19px; text-align: start; margin-bottom: 0; }
.dash-email { font-size: 12px; color: var(--muted); margin-bottom: 22px; }
.link-btn { background: none; border: none; color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: underline; }

/* Catalog tiles */
.tile { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--bd); border-radius: 12px; margin-bottom: 12px; color: var(--ink); transition: .15s; }
.tile .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--blue-tint); display: grid; place-items: center; flex: 0 0 auto; }
.tile .ic svg { width: 20px; height: 20px; stroke: var(--blue); fill: none; }
.tile .body { flex: 1; min-width: 0; }
.tile .t { font-weight: 700; font-size: 15px; }
.tile .d { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.6; }
.tile .price { font-size: 12.5px; font-weight: 800; margin-top: 6px; }
.tile .price .per { color: var(--muted); font-weight: 600; }
.tile.on { border-color: var(--ok); cursor: pointer; }
.tile.on:hover { background: var(--surface-2); }

.sub-btn { flex: 0 0 auto; padding: 9px 16px; background: var(--blue); color: #fff; border: none; border-radius: 9px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: .2s; }
.sub-btn:hover { background: var(--blue-dk); }
.sub-btn:disabled { opacity: .6; cursor: not-allowed; }
.badge-on { flex: 0 0 auto; font-size: 11px; font-weight: 700; background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); padding: 4px 10px; border-radius: 20px; }
.badge-due { flex: 0 0 auto; font-size: 11px; font-weight: 700; background: var(--err-bg); color: var(--err); border: 1px solid var(--err); padding: 4px 10px; border-radius: 20px; }

/* Spinner + loading */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 34px; height: 34px; border: 3px solid var(--bd); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 5000; }
.list-loading { display: flex; justify-content: center; padding: 30px; }

/* OMR symbol */
.omr-ic { height: .8em; width: auto; fill: currentColor; display: inline-block; vertical-align: -.03em; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(2, 6, 20, .55); display: flex; align-items: center; justify-content: center; z-index: 6000; padding: 20px; }
.modal { background: var(--surface); color: var(--ink); border: 1px solid var(--bd); border-radius: 16px; width: 100%; max-width: 420px; box-shadow: 0 24px 70px rgba(0, 0, 0, .4); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--bd); }
.modal-head h3 { font-size: 16px; font-weight: 800; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.modal-body { padding: 8px 18px 18px; }
.mrow { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--bd); font-size: 14px; }
.mrow:last-child { border-bottom: none; }
.mrow .k { color: var(--muted); flex: 0 0 auto; }
.mrow .v { font-weight: 700; text-align: end; word-break: break-word; }
.modal-note { font-size: 13.5px; line-height: 1.9; color: var(--ink); padding: 12px 0 4px; }
.modal-body .btn { margin-top: 14px; }

/* Floating theme + language toggles */
.theme-fab { position: fixed; top: 14px; left: 14px; z-index: 4000; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--bd); background: var(--surface); color: var(--ink); font-size: 17px; cursor: pointer; box-shadow: 0 6px 20px var(--shadow); display: grid; place-items: center; }
.theme-fab:hover { border-color: var(--blue); }
.lang-fab { top: 62px; font-size: 12px; font-weight: 800; }

/* OTP code input */
.otp-input { letter-spacing: 8px; font-size: 20px !important; font-weight: 800; text-align: center !important; }
