/* ==========================================================================
   Tijara UI — "Ledger"
   One design language for the dashboard, the license portal and the POS till.
   Canonical copy: E:\Tijara-Dashboard\public\tijara-ui.css  (copied into the portal and the POS — keep them identical).

   Idea: a trader's ledger. Warm paper, ink-green text, one deep teal that carries the interface, one saffron for
   whatever needs attention. Figures are always tabular. Cards that hold a number get a ticket-stub notch.
   Logical properties throughout, so Arabic (RTL) mirrors without a second stylesheet.
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap");

:root {
  --paper: #f3efe6;          /* page */
  --surface: #fffdf8;        /* cards */
  --surface-2: #f8f4ea;      /* wells, table heads */
  --ink: #14201f;
  --ink-2: #3a4846;
  --muted: #6b7773;
  --line: #e4ddcc;
  --line-strong: #cfc6b0;

  --brand: #0b5d57;          /* deep teal */
  --brand-hover: #084a45;
  --brand-ink: #ffffff;
  --brand-soft: #dcebe8;
  --rail: #0e2a28;           /* the dark spine behind navigation */
  --rail-ink: #d8e6e3;

  --accent: #e0991a;         /* saffron: attention */
  --accent-soft: #fbefd3;
  --ok: #2c7a4b;   --ok-soft: #dcefe2;
  --warn: #9a6408; --warn-soft: #fbefd3;
  --bad: #b3402a;  --bad-soft: #f8e1db;
  --info: #2c5f8a; --info-soft: #dfeaf4;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(20,32,31,.04), 0 10px 24px -16px rgba(20,32,31,.35);
  --ring: 0 0 0 3px rgba(11,93,87,.22);

  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-display: "IBM Plex Sans Arabic", "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(rgba(20,32,31,.045) 1px, transparent 1px);
  background-size: 18px 18px;           /* faint ledger dots */
  min-height: 100vh; display: flex; flex-direction: column;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---- type ---- */
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; margin-bottom: .25rem; }
h2 { font-size: 1.1rem; margin-bottom: 1rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; }
.subtitle, .tagline { color: var(--muted); font-size: .92rem; margin: 0 0 1.4rem; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.mono { font-family: var(--font-mono); font-size: .82em; letter-spacing: -.01em; }
a { color: var(--brand); }
a.link, .link-inline { color: var(--brand); text-decoration: none; font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; }
a.link:hover, .link-inline:hover { text-decoration: underline; }

/* ---- top bar ---- */
header {
  background: var(--rail); color: var(--rail-ink); display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 1.4rem; position: sticky; top: 0; z-index: 20; border-bottom: 3px solid var(--accent);
}
header .brand-block { display: flex; flex-direction: column; gap: 0; }
header .brand { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: #fff; letter-spacing: .01em; display: flex; align-items: center; gap: .6rem; }
header .brand::before {
  content: "T"; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--rail); font-weight: 800; font-size: 1.05rem;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
header .brand span { color: var(--accent); }
header .tagline { color: #93aaa6; font-size: .7rem; margin: 0; padding-inline-start: calc(30px + .6rem); letter-spacing: .03em; }
header nav, header .nav { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: #93aaa6; }
header nav a, header .nav a, header .link { color: var(--rail-ink); text-decoration: none; padding: .35rem .7rem; border-radius: 6px; background: none; border: 0; cursor: pointer; font: inherit; }
header nav a:hover, header .nav a:hover, header .link:hover { background: rgba(255,255,255,.1); color: #fff; }
header .credits { background: var(--accent); color: var(--rail); padding: .2rem .7rem; border-radius: 999px; font-weight: 700; font-size: .8rem; }
header form { margin: 0; }
header button.secondary { background: transparent; color: var(--rail-ink); border: 1px solid rgba(255,255,255,.25); box-shadow: none; margin: 0; }
header button.secondary:hover { background: rgba(255,255,255,.1); }
.banner { background: var(--accent); color: var(--rail); text-align: center; padding: .5rem; font-size: .88rem; font-weight: 600; }
.banner a { color: var(--rail); }

/* ---- shell: the dark rail + the page ---- */
.shell { display: flex; align-items: stretch; flex: 1; }
.sidebar {
  width: 224px; flex-shrink: 0; background: var(--rail); padding: 1.1rem .7rem 2rem; position: sticky; top: 0; align-self: flex-start;
  min-height: calc(100vh - 64px);
}
.sidebar a {
  display: flex; align-items: center; gap: .6rem; padding: .62rem .85rem; margin-bottom: .15rem; border-radius: 8px;
  color: var(--rail-ink); text-decoration: none; font-size: .9rem; font-weight: 500; border-inline-start: 3px solid transparent;
  transition: background .15s;
}
.sidebar a:hover { background: rgba(255,255,255,.08); }
.sidebar a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; border-inline-start-color: var(--accent); }
.sidebar .nav-sep { margin: 1rem .85rem .4rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #6f8a86; }
.main { flex: 1; min-width: 0; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 1.8rem 1.6rem 3rem; }
main { max-width: 1060px; margin: 0 auto; padding: 1.8rem 1.6rem 3rem; width: 100%; flex: 1; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-head .subtitle { margin: 0; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: .5rem; }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--brand); }

/* ---- cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.4rem;
  margin-bottom: 1.3rem; box-shadow: var(--shadow);
}
.card > h2:first-child { padding-bottom: .7rem; border-bottom: 1px dashed var(--line-strong); margin-bottom: 1rem; }
.card.narrow { max-width: 460px; }
.card.stripe { border-inline-start: 5px solid var(--stripe, var(--brand)); }
.card.stripe-warn { --stripe: var(--accent); border-inline-start: 5px solid var(--stripe); } .card.stripe-bad { --stripe: var(--bad); border-inline-start: 5px solid var(--stripe); } .card.stripe-ok { --stripe: var(--ok); border-inline-start: 5px solid var(--stripe); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.3rem; }
.grid-2 > .card { margin-bottom: 0; }
.kv { display: grid; grid-template-columns: 9rem 1fr; gap: .45rem .9rem; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }

/* ---- the ticket-stub stat tile: the memorable bit ---- */
.stats, .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat, .kpi {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .95rem 1.1rem 1rem; box-shadow: var(--shadow);
  --notch: var(--paper);
  -webkit-mask: radial-gradient(circle 7px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 7px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 7px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 7px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
}
.stat .label, .kpi span { display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.stat .value, .kpi b { display: block; font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; margin-top: .25rem; line-height: 1.1; color: var(--ink); }
.stat.hl { background: var(--brand); border-color: var(--brand); } .stat.hl .label { color: #b5d6d2; } .stat.hl .value { color: #fff; }
.kpi.warn b { color: var(--warn); } .kpi.bad b { color: var(--bad); }
.trend { display: block; font-size: .72rem; font-weight: 700; margin-top: .2rem; }
.trend.up { color: var(--ok); } .trend.down { color: var(--bad); } .trend.flat { color: var(--muted); }

/* ---- buttons ---- */
button, .btn, a.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; margin-top: 1rem; padding: .62rem 1.15rem;
  background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); border-radius: var(--radius-sm);
  font: 600 .88rem var(--font); cursor: pointer; text-decoration: none; box-shadow: 0 2px 0 rgba(0,0,0,.18);
  transition: transform .08s, background .15s, box-shadow .08s;
}
button:hover, .btn:hover, a.primary:hover { background: var(--brand-hover); }
button:active, .btn:active, a.primary:active { transform: translateY(2px); box-shadow: 0 0 0 rgba(0,0,0,0); }
button.secondary, .btn.secondary, a.btn { background: var(--surface); color: var(--brand); border-color: var(--line-strong); box-shadow: 0 2px 0 rgba(20,32,31,.08); }
button.secondary:hover, .btn.secondary:hover, a.btn:hover { background: var(--brand-soft); border-color: var(--brand); }
button.danger, .btn.danger { background: var(--surface); color: var(--bad); border-color: #e3b9ae; box-shadow: 0 2px 0 rgba(179,64,42,.14); }
button.danger:hover, .btn.danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.row-actions form { display: inline-flex; gap: .3rem; margin: 0; align-items: center; }
.row-actions button, .row-actions .btn, form.inline button { margin: 0; padding: .32rem .7rem; font-size: .8rem; }
.row-actions select { width: auto; padding: .3rem .5rem; font-size: .8rem; }
form.inline { margin: 0; display: flex; gap: .4rem; align-items: center; } form.inline input { margin: 0; }

/* ---- forms ---- */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-2); margin: .95rem 0 .3rem; letter-spacing: .01em; }
input, select, textarea {
  width: 100%; padding: .58rem .75rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff;
  font: .92rem var(--font); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: #a39e8e; }
textarea { resize: vertical; font-family: var(--font-mono); word-break: break-all; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
.search-form { display: flex; gap: .6rem; margin-bottom: 1.1rem; } .search-form input { flex: 1; width: auto; } .search-form button { margin: 0; }
.range-form { display: flex; gap: .7rem; align-items: flex-end; flex-wrap: wrap; } .range-form label { margin: 0 0 .3rem; } .range-form input[type=date] { width: auto; } .range-form button { margin-top: 0; }

/* ---- messages ---- */
.error, .err, .ok, .notice {
  border-radius: var(--radius-sm); padding: .65rem .95rem; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; border: 1px solid;
  border-inline-start-width: 5px;
}
.error, .err { color: var(--bad); background: var(--bad-soft); border-color: #e8bfb3; }
.ok { color: var(--ok); background: var(--ok-soft); border-color: #b8dcc4; }
.notice { color: var(--warn); background: var(--warn-soft); border-color: #ecd49a; }
.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: start; padding: .62rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; background: var(--surface-2); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
tbody tr:hover { background: rgba(11,93,87,.045); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: end; } td.center { text-align: center; }
tr.is-warn td:first-child { box-shadow: inset 4px 0 0 var(--accent); } tr.is-bad td:first-child { box-shadow: inset 4px 0 0 var(--bad); } tr.is-ok td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
[dir=rtl] tr.is-warn td:first-child { box-shadow: inset -4px 0 0 var(--accent); } [dir=rtl] tr.is-bad td:first-child { box-shadow: inset -4px 0 0 var(--bad); } [dir=rtl] tr.is-ok td:first-child { box-shadow: inset -4px 0 0 var(--ok); }
.table-wrap, .chart-wrap { overflow-x: auto; }

/* ---- badges, pills, tabs ---- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on, .badge.active { background: var(--ok-soft); color: var(--ok); border-color: #b8dcc4; }
.badge.off, .badge.expired, .badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #e8bfb3; }
.badge.expiring, .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #ecd49a; }
.badge.perpetual, .badge.info { background: var(--info-soft); color: var(--info); border-color: #bfd3e6; }
.pill, .tab { display: inline-block; padding: .32rem .85rem; margin: .12rem; border-radius: 999px; border: 1px solid var(--line-strong); font-size: .82rem; font-weight: 600; text-decoration: none; color: var(--ink-2); background: var(--surface); }
.pill:hover, .tab:hover { border-color: var(--brand); color: var(--brand); }
.pill.active, .tab.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: .35rem; } .dot.up { background: var(--ok); } .dot.down { background: var(--bad); }
.chart-bar-label { font-size: .65rem; fill: var(--muted); } .chart-bar-value { font-size: .65rem; fill: var(--ink); font-weight: 600; }

/* ---- sign-in ---- */
.auth { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card, .login-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--brand); border-radius: var(--radius); padding: 2rem 1.9rem; box-shadow: var(--shadow); }
.auth-mark { width: 54px; height: 54px; margin: 0 0 1rem; border-radius: 12px; display: grid; place-items: center; background: var(--rail); color: var(--accent); font: 800 1.6rem var(--font-display); border-bottom: 4px solid var(--accent); }
.auth-title { font-size: 1.45rem; margin: 0; } .auth-sub { color: var(--muted); font-size: .88rem; margin: .2rem 0 1rem; }
.auth-card form button, .login-card form button { width: 100%; margin-top: 1.3rem; padding: .75rem; font-size: 1rem; }

/* ---- small screens: the rail becomes a scrolling strip ---- */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; min-height: 0; display: flex; overflow-x: auto; gap: .3rem; padding: .5rem .6rem; }
  .sidebar a { white-space: nowrap; margin: 0; } .sidebar .nav-sep { display: none; }
  .wrap, main { padding: 1.1rem .9rem 2rem; }
  h1 { font-size: 1.45rem; } .kv { grid-template-columns: 1fr; }
  header { padding: .6rem .9rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { header, .sidebar, .banner, button { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

/* ---- portal & misc helpers ---- */
table.data { width: 100%; }
.quick-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.3rem; }
.quick-actions a { margin-top: 0; }
button.link { background: none; border: 0; box-shadow: none; color: var(--brand); padding: 0; margin: 0; font-weight: 600; }
button.link:hover { background: none; text-decoration: underline; }
form.payform { margin: 0; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
form.payform input { margin: 0; width: auto; } form.payform button { margin: 0; padding: .32rem .7rem; font-size: .8rem; }
label.pay { display: flex; align-items: center; gap: .3rem; margin: 0; color: var(--ink); font-size: .82rem; font-weight: 600; }
.tj-filter { max-width: 22rem; margin-bottom: .9rem; }

header button.link { color: var(--rail-ink); font-weight: 500; padding: .35rem .7rem; }
header button.link:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
