@font-face { font-family: Alexandria; src: url(assets/fonts/Alexandria-Variable.ttf) format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: Plex; src: url(assets/fonts/IBMPlexSansArabic-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Plex; src: url(assets/fonts/IBMPlexSansArabic-SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }

:root {
  --well: #0B5C57; --teal: #0E6B63; --ocher: #E3A33B; --ocher-soft: #FBEBD0; --ocher-ink: #7A4A06;
  --mint: #E0F0EB; --sand: #F6F1E6; --ink: #0F2A2A; --muted: #4E615F; --line: #E2DACB;
  --field: #7F8D8A; --clay: #9A3324; --clay-soft: #F8E6E2; --green: #2E7D32; --green-soft: #DDF1E2;
  --shadow: 0 8px 24px rgba(11, 92, 87, .08);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--sand); color: var(--ink); font: 400 16px/1.6 Plex, system-ui, sans-serif; }
h1, h2, h3 { font-family: Alexandria, Plex, sans-serif; margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ocher); outline-offset: 2px; border-radius: 8px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* fields: white with a visible edge, like the app */
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: #fff; border: 1.5px solid var(--field); border-radius: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border: 2.5px solid var(--teal); }
textarea { min-height: 96px; resize: vertical; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }

.btn {
  min-height: 50px; padding: 0 24px; border: 0; border-radius: 25px;
  background: var(--teal); color: #fff; font-weight: 600; font-size: 16px; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ocher { background: var(--ocher); color: var(--ink); }
.btn.line { background: transparent; color: var(--teal); border: 1.5px solid var(--teal); }
.ghost { background: transparent; border: 0; color: inherit; cursor: pointer; padding: 8px 10px; border-radius: 10px; font-weight: 600; }

/* ── login ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(var(--well) 0 42%, var(--sand) 42%); }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 24px; padding: 28px 24px;
  box-shadow: var(--shadow); display: grid; gap: 16px; }
.login-card img { border-radius: 16px; }
.login-card h1 { font-size: 24px; color: var(--well); }
.err { margin: 0; min-height: 1.4em; color: var(--clay); font-weight: 600; font-size: 15px; }

/* ── shell ── */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--well); color: #fff; }
.top img { border-radius: 10px; }
.top strong { font: 700 19px Alexandria, sans-serif; }
.top-sub { color: #CFE8E1; font-size: 14px; flex: 1; }
.nav { position: sticky; bottom: 0; order: 3; display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fff; box-shadow: 0 -4px 16px rgba(11, 92, 87, .08); }
.nav a { display: grid; justify-items: center; gap: 2px; padding: 8px 4px 10px; font-size: 13px; font-weight: 600;
  color: var(--muted); text-decoration: none; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"] svg { background: var(--ocher); border-radius: 12px; padding: 2px 10px; width: 44px; }
.view { padding: 20px 16px 28px; width: 100%; max-width: 1000px; margin-inline: auto; outline: none; }
@media (min-width: 900px) {
  .shell { grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / -1; }
  .nav { order: 0; position: sticky; top: 0; align-self: start; grid-template-columns: 1fr; gap: 4px;
    padding: 16px 12px; box-shadow: none; background: transparent; }
  .nav a { grid-template-columns: 28px 1fr; justify-items: start; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 14px; font-size: 15px; }
  .nav a[aria-current="page"] { background: #fff; box-shadow: var(--shadow); }
  .nav a[aria-current="page"] svg { background: none; padding: 0; width: 24px; color: var(--teal); }
  .view { padding: 28px 32px 40px; }
}

/* ── content pieces ── */
.page-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-h h2 { font-size: 24px; color: var(--well); }
.card { background: #fff; border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.section-h { font-size: 17px; margin: 26px 0 10px; }
.muted { color: var(--muted); }
.note { color: var(--muted); padding: 24px 0; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: #fff; border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat span { display: block; font-size: 14px; color: var(--muted); }
.stat b { font: 700 26px Alexandria, sans-serif; }
.stat.dl b { color: var(--ocher-ink); }
.stat.vis b { color: var(--well); }

.chart { margin-top: 10px; }
.chart svg { display: block; width: 100%; height: 180px; }
.legend { display: flex; gap: 16px; font-size: 14px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

.tag { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 13px; font-weight: 600; }
.tag.trial { background: var(--ocher-soft); color: var(--ocher-ink); }
.tag.active { background: var(--green-soft); color: var(--green); }
.tag.expired { background: var(--clay-soft); color: var(--clay); }

.toast { position: fixed; inset-inline: 16px; bottom: 84px; margin-inline: auto; width: fit-content; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ── forms and lists ── */
.form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--teal); }
.small { font-size: 14px; }
.form .muted.small { margin: -6px 0 0; }
.list { display: grid; gap: 12px; }
@media (min-width: 900px) { .list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rel { display: grid; gap: 4px; }
.rel p { margin: 0; }
.rel-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rel-v { font: 700 22px Alexandria, sans-serif; }
.rel-h .tag { margin-inline-start: auto; }
.btn.small { min-height: 42px; padding: 0 18px; font-size: 15px; justify-self: start; margin-top: 6px; }

.acc { display: grid; gap: 4px; }
.acc p { margin: 0; }
.acc-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.acc-h b { font: 700 18px Alexandria, sans-serif; }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.acc-actions .btn.small { margin-top: 0; }
.acc-date { display: flex; gap: 8px; flex: 1 1 220px; }
.acc-date input { min-height: 42px; flex: 1; }
.dlg { border: 0; border-radius: 22px; padding: 22px; width: min(360px, calc(100% - 32px)); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(15, 42, 42, .45); }
.dlg p { margin: 0 0 16px; font-size: 17px; font-weight: 600; }
.dlg-actions { display: flex; gap: 10px; }
.dlg-actions .btn { flex: 1; }
