/* ============ Almonasp platform — brand tokens ============ */
:root {
  --bg: #F3EEE4;
  --surface: #FFFDF9;
  --surface-2: #EFE9DD;
  --ink: #2B2B2B;
  --muted: #6B6F66;
  --green: #1F4D3A;
  --green-2: #2E6B52;
  --green-soft: rgba(31, 77, 58, .08);
  --copper: #A65E2E;
  --sand: #D9C6A5;
  --sage: #CFD9D1;
  --line: rgba(31, 77, 58, .16);
  --line-strong: rgba(31, 77, 58, .32);
  --shadow: 0 18px 50px rgba(31, 77, 58, .14);
  --shadow-sm: 0 4px 14px rgba(31, 77, 58, .08);
  --danger: #B3403A;
  --ok: #2E6B52;
  --on-green: #EFE9DD;
  --radius: 14px;
  --radius-sm: 9px;
  --body: 'IBM Plex Sans Arabic', 'Alexandria', system-ui, sans-serif;
  --display: 'Alexandria', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --latin: 'Lora', Georgia, serif;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #171B19;
  --surface: #212724;
  --surface-2: #1C2220;
  --ink: #EFE9DD;
  --muted: #A7ADA4;
  --green: #4F9A7A;
  --green-2: #6FB393;
  --green-soft: rgba(111, 179, 147, .12);
  --copper: #C8784A;
  --line: rgba(239, 233, 221, .14);
  --line-strong: rgba(239, 233, 221, .3);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .3);
  --danger: #E07A72;
  --ok: #6FB393;
  --on-green: #171B19;
  color-scheme: dark;
}

/* ============ base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
}
html[data-lang="ur"] body { font-family: 'Noto Nastaliq Urdu', var(--body); line-height: 2; }
html[data-lang="ur"] h1, html[data-lang="ur"] h2, html[data-lang="ur"] h3 { font-family: 'Noto Nastaliq Urdu', var(--display); line-height: 1.9; }
html[data-lang="en"] body { font-family: 'IBM Plex Sans Arabic', 'Lora', system-ui, sans-serif; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; line-height: 1.3; letter-spacing: 0; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip:focus { width: auto; height: auto; clip: auto; inset-inline-start: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 99; }
:root:not([data-theme="dark"]) .logo-dark { display: none !important; }

:root[data-theme="dark"] .logo-light { display: none !important; }

/* ============ topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand img { height: 38px; width: auto; display: block; }
.topbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.langs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang { padding: 3px 11px; border-radius: 999px; font-size: .82rem; font-weight: 500; color: var(--muted); line-height: 1.6; }
.lang:hover { text-decoration: none; color: var(--ink); }
.lang.is-active { background: var(--green); color: var(--on-green); }
.iconbtn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); display: inline-grid; place-items: center; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.iconbtn:hover { background: var(--green-soft); border-color: var(--line-strong); }
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn.danger { color: var(--danger); }
.theme-toggle .ico-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: block; }
.menu-toggle { display: none; }
.user { display: flex; align-items: center; gap: 8px; padding-inline-start: 10px; border-inline-start: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: var(--on-green); display: grid; place-items: center; font-family: var(--latin); font-weight: 600; font-size: .9rem; }
.user-name { font-size: .9rem; font-weight: 500; }
.logout { display: inline-grid; place-items: center; color: var(--muted); }
.logout svg { width: 20px; height: 20px; }
.logout:hover { color: var(--copper); }

/* ============ shell ============ */
.shell { display: flex; min-height: calc(100dvh - var(--topbar-h)); }
.sidebar {
  width: var(--sidebar-w); flex: none;
  padding: 18px 12px;
  border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h));
}
.sidenav { display: flex; flex-direction: column; gap: 4px; }
.sidenav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--ink); font-weight: 500;
}
.sidenav-item svg { width: 20px; height: 20px; color: var(--muted); }
.sidenav-item:hover { background: var(--green-soft); text-decoration: none; }
.sidenav-item.is-active { background: var(--green); color: var(--on-green); }
.sidenav-item.is-active svg { color: inherit; }
.sidebar-foot { margin-top: auto; padding: 8px 12px; }
.backdrop { display: none; }
.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1240px; }

/* ============ components ============ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.card h2 { margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 500; cursor: pointer; line-height: 1.4;
  transition: transform .1s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: var(--on-green); }
.btn-primary:hover { background: var(--green-2); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--green-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-ok { background: var(--green-soft); color: var(--ok); }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; transition: opacity .5s; }
.flash.is-hiding { opacity: 0; }
.flash-ok { background: var(--green-soft); border-color: var(--line); color: var(--ok); }
.flash-error { background: rgba(179, 64, 58, .08); border-color: rgba(179, 64, 58, .3); color: var(--danger); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 28px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.field > span, .field > legend { font-size: .86rem; font-weight: 500; color: var(--muted); padding: 0; }
.field input, .field select, .check-input, .row-item input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .95rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .check-input:focus, .row-item input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.field-sm { max-width: 160px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-item { position: relative; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; inset: 0; margin: 0; padding: 0; }
.seg-item span {
  display: inline-block; min-width: 52px; text-align: center;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; font-weight: 500; font-family: var(--display);
  transition: background .15s, color .15s, border-color .15s;
}
.seg-item:hover span { background: var(--green-soft); }
.seg-item input:checked + span { background: var(--green); border-color: var(--green); color: var(--on-green); }
.seg-item input:focus-visible + span { box-shadow: 0 0 0 3px var(--green-soft); }
.checks { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 16px; }
.check-row { display: grid; grid-template-columns: minmax(170px, 220px) 1fr; gap: 12px; align-items: center; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--green); margin: 0; }
.prefixed { display: flex; align-items: center; }
.prefixed > span { padding: 10px 10px; border: 1px solid var(--line-strong); border-inline-end: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); color: var(--muted); font-family: var(--latin); }
[dir="rtl"] .prefixed > span { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prefixed .check-input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
[dir="rtl"] .prefixed .check-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

/* services */
.services { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.service { display: flex; gap: 16px; align-items: flex-start; color: inherit; position: relative; transition: transform .15s, box-shadow .15s; }
.service:hover { text-decoration: none; }
.service.is-active:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.service.is-soon { opacity: .62; }
.service-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; flex: none; }
.service-ico svg { width: 26px; height: 26px; }
.service-body { flex: 1; min-width: 0; }
.service-body h2 { margin: 6px 0 4px; }
.service-arrow { position: absolute; inset-inline-end: 18px; bottom: 18px; color: var(--copper); width: 22px; height: 22px; }
[dir="rtl"] .service-arrow { transform: scaleX(-1); }

/* label page */
.label-layout { display: grid; grid-template-columns: 1fr; gap: 18px; margin-bottom: 18px; }
@media (min-width: 1080px) {
  .label-layout { grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); align-items: start; }
  .preview-card { position: sticky; top: calc(var(--topbar-h) + 18px); }
}
.preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.preview-wrap {
  position: relative; overflow: hidden; border-radius: var(--radius-sm);
  background: repeating-conic-gradient(var(--surface-2) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
  border: 1px solid var(--line); margin-bottom: 12px;
}
.preview-stage { position: absolute; top: 0; inset-inline-start: 0; width: 75mm; height: 50mm; transform-origin: top left; box-shadow: 0 8px 30px rgba(0, 0, 0, .18); }
[dir="rtl"] .preview-stage { transform-origin: top right; }
.preview-card .small { margin-bottom: 8px; }
.print-hint { margin-bottom: 14px !important; }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.recent-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.recent-main { display: flex; flex-direction: column; }
.recent-main strong { font-family: var(--display); font-size: 1.05rem; }

/* settings rows */
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.row-item { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: center; }
.rows-plain .row-item { grid-template-columns: 1fr auto; }
.settings-form .card { margin-bottom: 18px; }
.pw-form .btn { margin-top: 4px; }

/* ============ login ============ */
.login-page { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 520px); min-height: 100dvh; }
.login-art { position: relative; background: #1F4D3A; color: #EFE9DD; overflow: hidden; display: grid; place-items: center; }
.login-art::before {
  content: ""; position: absolute; inset: 0; opacity: .18;
  background: url("../img/pattern-sidr-inv.webp") center / 520px repeat;
}
.login-art-inner { position: relative; text-align: center; padding: 40px; }
.login-mark { width: 150px; height: auto; margin-bottom: 20px; }
.login-art-text { font-family: var(--display); font-size: 2.4rem; font-weight: 600; }
html[data-lang="en"] .login-art-text { font-family: var(--latin); font-weight: 500; }
.login-art-sub { opacity: .75; margin-top: 4px; }
.login-panel { display: flex; flex-direction: column; padding: 24px clamp(20px, 5vw, 56px); background: var(--bg); }
.login-tools { display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.login-card { margin: auto 0; width: 100%; max-width: 400px; align-self: center; }
.login-logo { height: 56px; width: auto; margin-bottom: 26px; }
.login-card h1 { margin-bottom: 6px; }
.login-card .muted { margin-bottom: 22px; }
.login-card .btn { margin-top: 8px; padding: 12px; }
.login-foot { text-align: center; }
@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-art { min-height: 200px; }
  .login-mark { width: 84px; margin-bottom: 10px; }
  .login-art-text { font-size: 1.7rem; }
}

/* ============ responsive ============ */
@media (max-width: 900px) {
  .menu-toggle { display: inline-grid; }
  .sidebar {
    position: fixed; inset-inline-start: 0; top: var(--topbar-h); z-index: 40;
    background: var(--surface); transform: translateX(-105%); transition: transform .2s;
    box-shadow: var(--shadow);
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  body.sidebar-open .sidebar { transform: none; }
  .backdrop { position: fixed; inset: 0; top: var(--topbar-h); background: rgba(0, 0, 0, .35); z-index: 35; }
  body.sidebar-open .backdrop { display: block; }
  .user-name { display: none; }
  .brand img { height: 32px; }
  .main { padding: 20px 16px 48px; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .check-row { grid-template-columns: 1fr; gap: 6px; }
  .row-item { grid-template-columns: 1fr 1fr; }
  .row-item input[type="text"]:nth-of-type(3) { grid-column: 1 / -1; }
  .recent-list li { grid-template-columns: 1fr auto; }
  .recent-list li > .small { grid-column: 1 / -1; }
  .page-head { flex-direction: column; }
}
@media (max-width: 480px) {
  .langs .lang { padding: 3px 8px; }
  .topbar { gap: 8px; padding: 0 12px; }
}

/* ============ THE LABEL (75 × 50 mm) ============ */
/* Shared by the on-screen preview and the print output. All dimensions in mm. */
.lbl {
  width: 75mm; height: 50mm; overflow: hidden;
  padding: 2.4mm 3mm 2.2mm;
  background: #fff; color: #1F4D3A;
  font-family: 'IBM Plex Sans Arabic', 'Alexandria', system-ui, sans-serif;
  display: flex; flex-direction: column;
  position: relative; line-height: 1.25;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.lbl i { font-style: normal; opacity: .5; margin: 0 .25em; }
.lbl .k { font-size: 2.1mm; color: #6B6F66; font-weight: 500; letter-spacing: .01em; white-space: nowrap; }
.lbl .v { font-family: 'Alexandria', 'IBM Plex Sans Arabic', sans-serif; font-weight: 600; white-space: nowrap; }
.lbl-head { display: flex; align-items: center; justify-content: space-between; gap: 2mm; height: 10mm; padding-bottom: 1.4mm; border-bottom: .3mm solid #1F4D3A; }
.lbl-logo { height: 8.2mm; width: auto; display: block; flex: none; }
.lbl-meta { display: flex; flex-direction: column; gap: .5mm; min-width: 0; text-align: end; }
.lbl-meta-row { display: flex; align-items: baseline; gap: 1.4mm; justify-content: flex-end; }
.lbl-meta-row .v { font-size: 3.1mm; }
.lbl-main { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 1.6mm; margin: 1.6mm 0; min-height: 0; }
.lbl-cell {
  border: .3mm solid #1F4D3A; border-radius: 1.6mm;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3mm; padding: .6mm 1mm; min-height: 0; overflow: hidden;
}
.lbl-cell .v { font-size: 12.5mm; line-height: 1; font-weight: 700; letter-spacing: -.01em; }
.lbl-cell .v:empty::before { content: "—"; opacity: .35; }
.lbl-foot {
  height: 5.4mm; flex: none;
  display: flex; align-items: center; justify-content: center; gap: 3mm;
  border-top: .2mm dashed #1F4D3A; padding-top: .9mm;
  font-family: 'Lora', 'IBM Plex Sans Arabic', serif; font-size: 2.5mm; direction: ltr;
}
.lbl-soc { display: inline-flex; align-items: center; gap: .9mm; white-space: nowrap; }
.lbl-soc svg { width: 2.7mm; height: 2.7mm; stroke-width: 1.7; color: #A65E2E; }
.lbl-soc b { font-weight: 500; }
.lbl-nofoot .lbl-main { margin-bottom: .6mm; }
.lbl-nofoot .lbl-cell .v { font-size: 14mm; }
.lbl-cl-ur .k { font-family: 'Noto Nastaliq Urdu', 'IBM Plex Sans Arabic', sans-serif; font-size: 2.1mm; line-height: 1.9; }
.lbl-cl-ur .lbl-meta { gap: 0; }
.lbl-cl-ur .lbl-meta-row { line-height: 1.9; align-items: center; }
.lbl-cl-ur .lbl-meta-row .v { font-family: 'Noto Nastaliq Urdu', 'IBM Plex Sans Arabic', sans-serif; font-size: 2.6mm; line-height: 1.9; }
.lbl-cl-ur .lbl-cell .k { font-size: 2.4mm; }
.lbl-cl-en .lbl-meta { text-align: end; }
.lbl-cl-en .k { letter-spacing: .04em; text-transform: uppercase; font-size: 1.9mm; }

/* print */
#print-root { display: none; }
@media print {
  @page { size: 75mm 50mm; margin: 0; }
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; position: static; }
  #print-root .lbl { page-break-after: always; break-after: page; margin: 0; }
  #print-root .lbl:last-child { page-break-after: auto; break-after: auto; }
}
