/* Rizq AlQuran Akademi — portal styles.
   Handwritten, no build step: the droplet has 1 vCPU and RAM to spare for nothing. */

:root {
  --green-900: #0f3d2e;
  --green-800: #14523c;
  --green-700: #1a6b4d;
  --green-600: #22855f;
  --green-100: #e6f4ee;
  --green-50:  #f2faf6;
  --gold-600:  #a97e26;
  --gold-500:  #c9992f;
  --gold-100:  #faf1d9;

  --ink:       #16211d;
  --ink-soft:  #4d5c56;
  --ink-faint: #7b8a84;
  --line:      #dbe5e0;
  --bg:        #f6f8f7;
  --card:      #ffffff;

  --red-600:   #b3261e;
  --red-100:   #fbe9e7;
  --amber-600: #9a6700;
  --amber-100: #fdf3d3;
  --blue-600:  #1f5f8b;
  --blue-100:  #e4f0f8;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,33,29,.06), 0 4px 12px rgba(16,33,29,.05);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.18rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--ink-faint); }
.soft { color: var(--ink-soft); }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- app shell */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--green-900); color: #dcebe4;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 1.05rem 1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar .brand .name { color: #fff; font-weight: 700; font-size: 1.02rem; line-height: 1.25; }
.sidebar .brand .sub { color: #8fb7a5; font-size: .76rem; letter-spacing: .03em; text-transform: uppercase; }
.sidebar nav { padding: .6rem 0; overflow-y: auto; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem 1rem; color: #cfe3d9; font-size: .93rem; text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--gold-500); font-weight: 600; }
.sidebar nav a .ic { width: 1.1rem; text-align: center; opacity: .9; }
.sidebar nav a .pill {
  margin-inline-start: auto; background: var(--gold-500); color: #3a2c05;
  font-size: .72rem; font-weight: 700; border-radius: 999px; padding: .05rem .42rem;
}
.sidebar .foot { padding: .7rem 1rem; border-top: 1px solid rgba(255,255,255,.1); font-size: .8rem; color: #8fb7a5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: .6rem 1.25rem; display: flex; align-items: center; gap: .8rem;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 650; font-size: 1.02rem; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; color: var(--ink-soft); text-align: right; line-height: 1.3; }
.topbar .who b { display: block; color: var(--ink); }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .55rem; font-size: 1.1rem; }

.langswitch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.langswitch a { padding: .18rem .6rem; font-size: .8rem; color: var(--ink-soft); }
.langswitch a.on { background: var(--green-700); color: #fff; font-weight: 600; }
.langswitch a:hover { text-decoration: none; }

.content { padding: 1.25rem; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------- pieces */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card > .card-head {
  padding: .7rem 1rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}
.card > .card-head h2, .card > .card-head h3 { margin: 0; }
.card > .card-head .spacer { flex: 1; }
.card > .card-body { padding: 1rem; }
.card > .card-body.tight { padding: .5rem 1rem; }

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem .9rem; box-shadow: var(--shadow);
}
.stat .label { font-size: .78rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; color: var(--green-800); font-variant-numeric: tabular-nums; }
.stat .value.warn { color: var(--amber-600); }
.stat .value.bad { color: var(--red-600); }
.stat .sub { font-size: .8rem; color: var(--ink-faint); }
.stat a { display: block; color: inherit; }
.stat a:hover { text-decoration: none; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .44rem .85rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: .9rem; font-weight: 550;
  cursor: pointer; text-decoration: none; font-family: inherit; line-height: 1.4;
}
.btn:hover { background: var(--green-50); text-decoration: none; border-color: var(--green-600); }
.btn.primary { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn.primary:hover { background: var(--green-800); border-color: var(--green-800); }
.btn.gold { background: var(--gold-500); border-color: var(--gold-500); color: #3a2c05; }
.btn.gold:hover { background: var(--gold-600); border-color: var(--gold-600); color: #fff; }
.btn.danger { color: var(--red-600); border-color: #e8c4c0; }
.btn.danger:hover { background: var(--red-100); border-color: var(--red-600); }
.btn.sm { padding: .25rem .55rem; font-size: .82rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btnrow { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------------- forms */
.field { margin-bottom: .85rem; }
.field > label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .22rem; color: var(--ink-soft); }
.field .hint { font-size: .78rem; color: var(--ink-faint); margin-top: .18rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: .46rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: .92rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-600); outline-offset: -1px; border-color: var(--green-600); }
textarea { min-height: 90px; resize: vertical; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 1rem; }
.formgrid .full { grid-column: 1 / -1; }
.checkline { display: flex; align-items: flex-start; gap: .5rem; }
.checkline input { margin-top: .25rem; }
.inline-form { display: inline; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 140px; }

/* ------------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .5rem .6rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 650; background: var(--green-50); white-space: nowrap; }
table.data tbody tr:hover { background: var(--green-50); }
table.data td.num, table.data th.num { text-align: end; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 650; border-top: 2px solid var(--line); }
.empty { padding: 1.6rem; text-align: center; color: var(--ink-faint); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-block; padding: .1rem .48rem; border-radius: 999px;
  font-size: .76rem; font-weight: 650; white-space: nowrap;
  background: var(--green-100); color: var(--green-800);
}
.badge.grey  { background: #eceff0; color: var(--ink-soft); }
.badge.amber { background: var(--amber-100); color: var(--amber-600); }
.badge.red   { background: var(--red-100); color: var(--red-600); }
.badge.blue  { background: var(--blue-100); color: var(--blue-600); }
.badge.gold  { background: var(--gold-100); color: var(--gold-600); }

/* ------------------------------------------------------------------- alerts */
.alert { padding: .65rem .85rem; border-radius: 8px; margin-bottom: .9rem; border: 1px solid; font-size: .9rem; }
.alert.ok   { background: var(--green-100); border-color: #b9dcca; color: var(--green-800); }
.alert.warn { background: var(--amber-100); border-color: #e8d59a; color: var(--amber-600); }
.alert.err  { background: var(--red-100); border-color: #eec4c0; color: var(--red-600); }
.alert.info { background: var(--blue-100); border-color: #bcd8ea; color: var(--blue-600); }

/* --------------------------------------------------------- needs attention */
.attn { border-inline-start: 4px solid var(--gold-500); }
.attn ul { list-style: none; margin: 0; padding: 0; }
.attn li {
  display: flex; align-items: center; gap: .6rem; padding: .5rem 0;
  border-bottom: 1px solid var(--line); font-size: .9rem;
}
.attn li:last-child { border-bottom: 0; }
.attn li .grow { flex: 1; min-width: 0; }
.attn li .count {
  min-width: 1.7rem; height: 1.7rem; border-radius: 999px; background: var(--gold-500); color: #3a2c05;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .82rem;
}

/* ----------------------------------------------------------------- calendar */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint);
  padding: .35rem; border-bottom: 1px solid var(--line); font-weight: 650;
}
.cal td { border: 1px solid var(--line); vertical-align: top; height: 96px; padding: .25rem; width: 14.28%; }
.cal td.out { background: #fafbfb; }
.cal td.today { background: var(--gold-100); }
.cal .daynum { font-size: .78rem; color: var(--ink-faint); font-weight: 650; }
.cal .ev {
  display: block; font-size: .74rem; padding: .1rem .3rem; border-radius: 5px; margin-top: .12rem;
  background: var(--green-100); color: var(--green-800); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-inline-start: 3px solid var(--green-600);
}
.cal .ev:hover { text-decoration: none; filter: brightness(.96); }
.cal .ev.postponed { background: var(--amber-100); color: var(--amber-600); border-color: var(--amber-600); text-decoration: line-through; }
.cal .ev.cover { background: var(--red-100); color: var(--red-600); border-color: var(--red-600); }
.cal .ev.completed { background: #eceff0; color: var(--ink-soft); border-color: var(--ink-faint); }
.cal .ev.extra { background: var(--gold-100); color: var(--gold-600); border-color: var(--gold-500); }

.legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .8rem; color: var(--ink-soft); }
.legend span::before { content: ''; display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-inline-end: .3rem; vertical-align: middle; }
.legend .l-sched::before { background: var(--green-600); }
.legend .l-done::before  { background: var(--ink-faint); }
.legend .l-post::before  { background: var(--amber-600); }
.legend .l-cover::before { background: var(--red-600); }
.legend .l-extra::before { background: var(--gold-500); }

/* ------------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,33,29,.55); display: none;
  align-items: center; justify-content: center; padding: 1rem; z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; max-width: 520px; width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.28); overflow: hidden;
}
.modal .m-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal .m-body { padding: 1.1rem; }
.modal .m-foot { padding: .85rem 1.1rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------ public pages */
.public {
  min-height: 100vh; background: linear-gradient(160deg, var(--green-900), var(--green-700) 60%, var(--green-600));
  padding: 1.5rem 1rem; display: flex; align-items: flex-start; justify-content: center;
}
.public .sheet { background: #fff; border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.22); width: 100%; max-width: 760px; overflow: hidden; }
.public .sheet.narrow { max-width: 430px; }
.public .sheet-head { background: var(--green-800); color: #fff; padding: 1.3rem 1.5rem; }
.public .sheet-head .name { font-size: 1.3rem; font-weight: 700; }
.public .sheet-head .sub { color: #a8ccbc; font-size: .88rem; }
.public .sheet-body { padding: 1.4rem 1.5rem; }
.public .sheet-foot { padding: .9rem 1.5rem; background: var(--green-50); border-top: 1px solid var(--line); font-size: .86rem; }

.rulesbox {
  border: 1px solid var(--line); border-radius: 8px; background: var(--green-50);
  padding: 1rem; max-height: 330px; overflow-y: auto; font-size: .87rem;
  white-space: pre-wrap; line-height: 1.6;
}
.steps { display: flex; gap: .4rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.steps .step { flex: 1; min-width: 110px; font-size: .8rem; padding: .35rem .5rem; border-radius: 6px; background: #eceff0; color: var(--ink-faint); text-align: center; }
.steps .step.on { background: var(--green-700); color: #fff; font-weight: 650; }
.steps .step.done { background: var(--green-100); color: var(--green-800); }

.paybox { border: 2px dashed var(--gold-500); border-radius: 10px; padding: 1rem; background: var(--gold-100); }
.paybox .amt { font-size: 1.7rem; font-weight: 750; color: var(--green-800); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; font-size: .9rem; }
.kv dt { color: var(--ink-faint); }
.kv dd { margin: 0; font-weight: 550; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 900px) {
  .formgrid, .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .menu-btn { display: inline-block; }
  .sidebar {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 60; height: 100vh;
    transform: translateX(-105%); transition: transform .18s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
  .content { padding: .9rem; }
  .cal td { height: auto; min-height: 62px; }
  .cal .ev { font-size: .68rem; }
  .topbar .who { display: none; }
}

/* ------------------------------------------------------------------- print
   Two label layouts from one set of markup: A6 one-up, or A4 with four A6
   cells in a 2x2 grid. Payslips print A4. */
.printonly { display: none; }
@media print {
  .sidebar, .topbar, .page-head .actions, .btn, .no-print, .filters { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .layout { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; margin: 0; }
  .printonly { display: block; }
  a { color: inherit; text-decoration: none; }
}

.labelsheet { display: none; }
@media print {
  .labelsheet { display: block; }
  .label {
    border: 1px dashed #999; padding: 8mm 7mm; overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between;
  }
  .label .from { font-size: 8pt; color: #444; border-bottom: 1px solid #bbb; padding-bottom: 2mm; margin-bottom: 3mm; }
  .label .to-label { font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: #666; }
  .label .to-name { font-size: 13pt; font-weight: 700; margin: 1mm 0 2mm; }
  .label .to-addr { font-size: 11pt; line-height: 1.45; white-space: pre-line; }
  .label .to-phone { font-size: 11pt; margin-top: 2mm; font-weight: 600; }
  .label .kitname { font-size: 8pt; color: #666; margin-top: 3mm; }
}

/* A6: one label per page */
@media print {
  body.print-a6 .labelsheet { }
  body.print-a6 .label { width: 105mm; height: 148mm; page-break-after: always; border: 0; }
}
@page a6 { size: A6 portrait; margin: 0; }
body.print-a6 { }

/* A4: four A6 cells, 2 x 2 */
@media print {
  body.print-a4 .labelsheet { display: grid; grid-template-columns: 105mm 105mm; grid-auto-rows: 148mm; }
  body.print-a4 .label { width: 105mm; height: 148mm; }
  body.print-a4 .labelsheet > .label:nth-child(4n) { page-break-after: always; }
}

/* payslip */
.payslip { max-width: 190mm; margin: 0 auto; }
.payslip .ps-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--green-800); padding-bottom: .6rem; margin-bottom: .9rem; }
.payslip .ps-title { font-size: 1.2rem; font-weight: 750; color: var(--green-800); }
.payslip table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.payslip th, .payslip td { padding: .38rem .5rem; border-bottom: 1px solid var(--line); text-align: start; }
.payslip td.num, .payslip th.num { text-align: end; font-variant-numeric: tabular-nums; }
.payslip .net { font-size: 1.05rem; font-weight: 750; border-top: 2px solid var(--green-800); }
@media print { .payslip { page-break-after: always; } .payslip:last-child { page-break-after: auto; } }
