@font-face {
  font-family: "IBM Plex Arabic";
  src: url("/assets/plex-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Arabic";
  src: url("/assets/plex-medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Arabic";
  src: url("/assets/plex-semibold.woff2") format("woff2");
  font-weight: 600 900;
  font-display: swap;
}

:root {
  --brand: #147654;
  --brand-deep: #10382c;
  --brand-soft: #e8f5ed;
  --ink: #192e26;
  --muted: #5e7067;
  --border: #dce6df;
  --surface: #fff;
  --page: #f3f7f4;
  --danger: #a13636;
  --radius: 15px;
  --sidebar-width: 238px;
  font-family: "IBM Plex Arabic", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-inline-size: 310px; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #2a916d; outline-offset: 3px; }
::selection { color: var(--brand-deep); background: #c3efd7; }
bdi, .number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.skip-link { position: fixed; z-index: 10; inset: 10px 10px auto auto; transform: translateY(-160%); padding: .5rem 1rem; border-radius: 8px; background: white; }
.skip-link:focus { transform: translateY(0); }

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  inset-block-start: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  background: var(--brand-deep);
  color: #e1eee5;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 3px 10px; color: #fff; text-decoration: none; }
.brand strong { display: block; font-size: 24px; line-height: 1.2; }
.brand small { display: block; color: #b5cfc0; font-size: 11px; margin-block-start: 3px; }
.brand-mark { flex: none; width: 41px; height: 41px; display: grid; place-items: center; border-radius: 12px; background: #bcf1ce; color: var(--brand-deep); }
.sidebar nav { display: grid; gap: 5px; margin-top: 30px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 8px 12px; border-radius: 9px; text-decoration: none; font-size: 14px; }
.nav-link:hover { background: #ffffff12; }
.nav-link[aria-current="page"] { background: #245441; color: #fff; font-weight: 600; }
.nav-link[aria-current="page"] svg { color: #b7efc8; }
.sidebar-context { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 15px 9px 0; border-top: 1px solid #ffffff2a; font-size: 12px; color: #b5cfc0; }
.workspace { min-width: 0; }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-start, .topbar-actions, .breadcrumbs { display: flex; align-items: center; gap: 10px; }
.breadcrumbs { font-size: 13px; color: var(--muted); }
.breadcrumbs strong { color: var(--ink); font-size: 14px; }
.breadcrumbs svg { color: #74867c; }
.topbar .search-launch { color: var(--muted); min-width: 192px; justify-content: flex-start; }
.topbar .search-launch .keycap { margin-inline-start: auto; color: var(--muted); padding: 0 5px; border: 1px solid var(--border); border-radius: 5px; font: 11px/1.6 "Segoe UI", sans-serif; }
.topbar .mobile-menu { display: none; }
.session-menu { position: relative; min-width: 0; }
.session-menu summary { cursor: pointer; list-style: none; }
.session-menu summary::-webkit-details-marker { display: none; }
.session-menu summary span { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; }
.session-actions { position: absolute; z-index: 4; inset: calc(100% + 6px) auto auto 0; min-width: 140px; display: grid; gap: 4px; padding: 5px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: 0 8px 22px #16322724; }
.session-actions .button { justify-content: flex-start; border-color: transparent; }
main { max-width: 1600px; padding: 26px 28px 42px; margin-inline: auto; outline: none; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.page-heading h1 { font-size: clamp(27px, 2.8vw, 37px); line-height: 1.22; font-weight: 700; }
.page-heading p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.loading, .load-error { padding: 30px; color: var(--muted); }
.load-error .button { margin-block-start: 12px; }
.button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { border-color: #a7c7b5; background: #f7faf8; }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover { background: #0d6043; border-color: #0d6043; }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.danger:hover { background: #872b2b; border-color: #872b2b; }
.button.icon-only { min-width: 36px; min-height: 36px; padding: 5px; }
.text-link { color: var(--brand); font-weight: 600; text-underline-offset: 3px; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 18px; }
.panel-head h2 { font-size: 19px; line-height: 1.4; }
.panel-head p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.panel-head > a { font-size: 13px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: stretch; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 14px 15px 13px; display: grid; gap: 3px; }
.kpi-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.kpi strong { display: block; font-size: clamp(20px, 2.2vw, 28px); letter-spacing: -.035em; line-height: 1.3; }
.kpi small { color: var(--muted); font-size: 11px; }
.glyph { flex: none; display: inline-grid; place-items: center; width: 33px; height: 33px; border-radius: 9px; color: #147654; background: #e7f5ec; }
.glyph.gold { color: #88621c; background: #fbf1d8; }
.glyph.blue { color: #3e5f8f; background: #ebf0f9; }
.glyph.red { color: #a23d3d; background: #faeeee; }
.glyph.neutral { color: #456858; background: #edf3ee; }
.select-control { min-height: 36px; max-width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: var(--surface); font-size: 13px; }
.chart-panel { min-height: 279px; }
.chart { padding: 0 11px 6px; display: block; width: 100%; height: auto; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--muted); }
.chart line { stroke: #e6eee9; stroke-dasharray: 4 4; }
.chart .sales-bar { fill: #86c9a6; }
.chart .sales-bar.current { fill: var(--brand); }
.chart .sales-bar:hover { fill: #16543d; }
.chart-key { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.chart-key::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--brand); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 13px 13px; }
.quick-action { display: grid; grid-template-columns: min-content 1fr; gap: 7px; align-items: center; padding: 10px 8px; min-height: 59px; border: 1px solid var(--border); border-radius: 10px; color: var(--ink); background: #fff; text-decoration: none; text-align: start; font-size: 12px; font-weight: 500; }
.quick-action:hover { background: #f6fbf7; border-color: #b7d5c4; }
.quick-action .glyph { width: 30px; height: 30px; }
.stock-list { padding: 0 17px 12px; margin: 0; list-style: none; }
.stock-list li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid #edf1ee; font-size: 13px; }
.stock-item { display: flex; align-items: center; gap: 8px; }
.stock-item small { display: block; color: var(--muted); font-size: 11px; }
.stock-count { color: #87581d; background: #fbf2de; border-radius: 5px; padding: 2px 7px; white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; padding: 13px 15px; align-items: center; }
.search-field { display: flex; min-width: min(100%, 220px); align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--muted); }
.search-field:focus-within { outline: 2px solid #2a916d; outline-offset: 1px; }
.search-field input { width: 100%; min-width: 0; min-height: 36px; padding: 4px 0; border: 0; outline: none; background: transparent; color: var(--ink); }
.table-scroll { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: start; font-size: 13px; line-height: 1.5; white-space: nowrap; }
.data-table :is(th, td) { text-align: start; padding: 10px 14px; border-bottom: 1px solid #edf1ee; }
.data-table th { color: var(--muted); background: #f6f9f6; font-weight: 500; border-top: 1px solid #edf1ee; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f9fbf9; }
.data-table td.empty-cell { padding: 26px 13px; text-align: center; color: var(--muted); }
.table-foot { padding: 10px 15px; border-top: 1px solid #edf1ee; color: var(--muted); font-size: 12px; }
.item-barcode { display: block; color: var(--muted); font-size: 11px; }
.status { display: inline-flex; align-items: center; gap: 4px; border-radius: 20px; padding: 3px 8px; font-size: 11px; font-weight: 600; color: #53675d; background: #edf1ee; }
.status.paid { color: #176748; background: #e4f4ea; }
.status.partial { color: #795600; background: #fcf0d0; }
.status.unpaid { color: #445c84; background: #eaf0fa; }
.status.overdue { color: #943c3c; background: #faeaea; }
.status.void { color: #58605d; background: #edf0ee; }
.empty-message { color: var(--muted); padding: 10px 17px 18px; font-size: 13px; }
.row-actions { display: flex; align-items: center; gap: 5px; }
.view-tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.view-tabs .button[aria-current] { background: var(--brand-soft); border-color: #b5d4c2; color: var(--brand-deep); }
.numeric-up { color: #167353; }
.numeric-down { color: #a13636; }
.field { display: grid; align-content: start; min-width: 0; gap: 5px; color: var(--ink); font-size: 13px; font-weight: 500; }
.field :is(input, textarea, select) { width: 100%; min-width: 0; min-height: 38px; padding: 6px 9px; border: 1px solid #cedcd4; border-radius: 8px; color: var(--ink); background: #fff; font-size: 14px; font-weight: 400; }
.field textarea { resize: vertical; }
.field small { color: var(--muted); font-weight: 400; }
dialog { width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); background: var(--surface); box-shadow: 0 22px 70px #142d2650; }
dialog::backdrop { background: #0f2e24a0; }
.dialog-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 17px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 20px; }
.dialog-form, .lookup { padding: 16px 17px; }
.form-grid { display: grid; gap: 13px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.toast { z-index: 12; position: fixed; inset: auto auto 18px 18px; max-width: min(420px, calc(100vw - 36px)); padding: 10px 16px; border-radius: 10px; color: white; background: var(--brand-deep); font-size: 14px; box-shadow: 0 8px 22px #1632273a; }
.toast.error { background: var(--danger); }
.lookup .search-field { width: 100%; }
.lookup-results { padding: 10px 0 0; }
.lookup-results a { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; text-decoration: none; font-size: 14px; }
.lookup-results a:hover { background: var(--brand-soft); }
.lookup-results small { margin-inline-start: auto; color: var(--muted); }

@media (max-width: 1100px) {
  :root { --sidebar-width: 195px; }
  main, .topbar { padding-inline: 19px; }
  .kpi { padding-inline: 11px; }
}
@media (max-width: 870px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart { max-height: 235px; }
}
@media (max-width: 700px) {
  .shell { display: block; }
  .sidebar { display: none; position: fixed; z-index: 6; inset: 0 0 0 auto; width: min(260px, 84vw); height: 100%; box-shadow: -10px 0 35px #18302750; }
  .sidebar.open { display: flex; }
  .topbar .mobile-menu { display: inline-flex; }
  .topbar .search-launch { min-width: 0; }
  .search-launch .keycap { display: none; }
  .topbar { padding-inline: 12px; min-height: 58px; }
  main { padding: 17px 12px 28px; }
}
@media (max-width: 425px) {
  .kpi-grid { gap: 8px; }
  .kpi strong { font-size: 19px; }
  .kpi-top { font-size: 12px; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .breadcrumbs > :not(strong) { display: none; }
  .session-menu summary span { max-width: 7ch; }
  .form-grid { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .skip-link, .toast { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
}
