/* MWT One SaaS v2.0 — MWT One pharmacy theme: deep navy + cyan.
   Layout patterns reused from MWT DocFlow (sidebar nav scrolls inside the
   panel; mobile sidebar is off-canvas behind the hamburger). */
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: #F2F5F9; color: #1c2733; font-size: 15px; line-height: 1.5; }
a { color: var(--primary, #0A2A52); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
/* Visible keyboard focus everywhere (navy ring, Req 15 polish):
   buttons, links, nav items, inputs, selects and the menu button. */
:focus-visible { outline: 3px solid rgba(4,182,210,.65); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; width: 100%; max-width: 400px; border-radius: 14px;
  box-shadow: 0 10px 40px rgba(10,42,82,.18); padding: 34px 30px; }
.login-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--primary);
  color: #fff; font-size: 28px; font-weight: 800; display: flex; align-items: center;
  justify-content: center; margin-bottom: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; color: var(--primary); }
.login-card p.sub { margin: 0 0 22px; color: #66788a; font-size: 14px; }

/* app shell */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex: 0 0 260px; background: var(--primary); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.14); }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; background: var(--secondary);
  color: #fff; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.brand-tenant { font-size: 11px; opacity: .75; line-height: 1.35; margin-top: 2px; }
.nav { padding: 14px 12px; flex: 1; min-height: 0; overflow-y: auto; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); border-radius: 3px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-link { display: block; padding: 11px 14px; border-radius: 9px; color: #dbe7f3;
  font-weight: 600; font-size: 14.5px; margin-bottom: 3px; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--secondary); color: #fff; }
.nav-link:focus-visible { outline-color: #fff; }
/* License-locked nav item (Req 19 — desktop LOCK RULE): visible but dimmed
   and completely inert. Same padding/typography as .nav-link so the
   sidebar layout does not shift; NOT a link, no hover effect. */
.nav-locked { display: block; padding: 11px 14px; border-radius: 9px; color: #dbe7f3;
  font-weight: 600; font-size: 14.5px; margin-bottom: 3px;
  opacity: .45; filter: blur(.5px) saturate(.5); cursor: not-allowed;
  user-select: none; }
.nav-count { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 12px;
  background: var(--secondary); color: #fff; font-size: 12px; font-weight: 800; text-align: center; }
.side-user { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.14); font-size: 13px; }
.side-user-name { font-weight: 700; }
.side-user-role { opacity: .75; margin-top: 2px; }
.side-user a { color: var(--secondary); }
.side-foot { padding: 10px 20px 14px; font-size: 11.5px; line-height: 1.5;
  color: rgba(255,255,255,.6); text-align: center; }
.main { flex: 1; padding: 28px 32px 40px; min-width: 0; }
/* Very wide screens: keep the content column readable, like the
   desktop app's windowed 1360px design (PLAN.md WINDOWED-DESIGN RULE). */
@media (min-width: 1600px) { .main { max-width: 1280px; margin: 0 auto; } }
.topbar { display: flex; justify-content: flex-end; align-items: center; padding: 0 0 14px; gap: 10px; }
/* Platform-admin tenant picker (lib.php): match the toolbar controls
   instead of the browser default. */
.tenant-picker { display: flex; gap: 8px; align-items: center; }
.tenant-picker select { padding: 9px 12px; border: 1.5px solid #cbd5e1; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: #1c2733; max-width: 220px; }
.tenant-picker select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,42,82,.12); }
.tenant-picker button { padding: 9px 14px; border-radius: 8px; border: 0; cursor: pointer;
  font-size: 14px; font-weight: 700; font-family: inherit; background: var(--primary); color: #fff; }
.tenant-picker button:hover { filter: brightness(1.12); }
.menu-btn { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  .main { padding: 20px 16px 32px; }
  .topbar { justify-content: space-between; }
  .tenant-picker select { max-width: 160px; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 10px; border: 0; cursor: pointer;
    background: var(--primary); color: #fff; font-size: 22px; line-height: 1; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    width: 280px; flex-basis: 280px; height: 100vh; height: 100dvh;
    transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 90;
    background: rgba(10,42,82,.45); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

h1.page-title { margin: 0 0 4px; font-size: 26px; color: var(--primary); }
.page-sub { color: #66788a; margin: 0 0 22px; font-size: 14px; }

/* cards + stats */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border: 1px solid #e8edf2; border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 4px rgba(16,24,40,.07); }
.stat-num { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1.1; overflow-wrap: break-word; }
.stat-label { color: #66788a; font-size: 13px; margin-top: 4px; }
.stat-accent { border-top: 4px solid var(--secondary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > * { min-width: 0; } /* lets cards shrink below their table's min-content width so .tbl-wrap scrolls instead of the page overflowing (Req 14, 390px dashboard fix) */
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.card h2 { margin: 0 0 12px; font-size: 17px; color: var(--primary); }
.card h3 { margin: 0 0 8px; font-size: 15px; }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px;
  overflow: hidden; box-shadow: 0 1px 4px rgba(16,24,40,.07); }
/* A table inside a card must not draw its own card shadow/edge. */
.card table.tbl { box-shadow: none; border-radius: 0; }
.tbl th { background: var(--primary); color: #fff; text-align: left; padding: 11px 14px;
  font-size: 13px; letter-spacing: .2px; }
.tbl td { padding: 11px 14px; border-top: 1px solid #e8edf2; font-size: 14px; vertical-align: top; }
.tbl tr:nth-child(even) td { background: #f8fafc; }
.tbl tbody tr:hover td { background: #eef4fa; }
.tbl .num { font-weight: 700; color: var(--primary); white-space: nowrap; }
.tbl-wrap { overflow-x: auto; border-radius: 12px; -webkit-overflow-scrolling: touch; }
.muted { color: #66788a; font-size: 13px; }
.mono { font-family: Consolas, monospace; font-size: 13px; }
.empty { text-align: center; color: #66788a; padding: 34px 10px; }
/* Standalone empty state (a <p>, not a table cell): a soft dashed box
   so an empty list reads as intentional, not broken. */
p.empty { border: 1.5px dashed #cbd5e1; border-radius: 10px; background: #f8fafc;
  padding: 22px 14px; font-size: 14px; }

/* badges + buttons */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.b-grey { background: #e8edf2; color: #475569; }
.b-amber { background: #fef3c7; color: #92400e; }
.b-green { background: #dcfce7; color: #166534; }
.b-red { background: #fee2e2; color: #991b1b; }
.b-blue { background: #dbeafe; color: #1e40af; }
/* Gold is a real gold, distinct from amber (they were near-identical). */
.b-gold { background: #fde68a; color: #713f12; }
.btn { display: inline-block; padding: 10px 18px; border-radius: 9px; border: 0; cursor: pointer;
  font-size: 14px; font-weight: 700; font-family: inherit; background: var(--primary); color: #fff;
  transition: filter .12s ease, transform .05s ease; white-space: nowrap; }
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-secondary { background: var(--secondary); }
.btn-ghost { background: #e8edf2; color: #1c2733; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: #b91c1c; }
a.btn, a.btn:hover { color: #fff; text-decoration: none; }
a.btn-ghost, a.btn-ghost:hover { color: #1c2733; }

/* forms */
.form-card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 4px rgba(16,24,40,.07);
  max-width: 720px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 5px; }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password],
.form-row input[type=date], .form-row input[type=number], .form-row input[type=file],
.form-row select, .form-row textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 15px; font-family: inherit; background: #fff; color: #1c2733; }
.form-row input[type=file] { padding: 8px 12px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,42,82,.12); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  h1.page-title { font-size: 22px; }
  .toolbar input[type=text] { min-width: 0; }
  /* Two stat cards per row on phones (desktop shows six in a row);
     smaller numbers so money values fit without overflow. */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card { padding: 14px 16px; }
  .stat-num { font-size: 20px; }
  .stat-label { font-size: 12px; }
  /* A4 receipt on phones: tighter padding, totals full-width, smaller type. */
  .receipt { padding: 16px 14px; }
  .receipt-totals { width: 100%; }
  .receipt-tbl { font-size: 13px; }
  .receipt-head h1 { font-size: 19px; }
}
.help { font-size: 12.5px; color: #66788a; margin-top: 4px; }

/* toolbar / filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=text], .toolbar input[type=date], .toolbar input[type=number],
.toolbar select { padding: 9px 12px; border: 1.5px solid #cbd5e1;
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: #1c2733;
  max-width: 100%; }
.toolbar input[type=text] { min-width: 260px; flex: 1; }
.toolbar input:focus, .toolbar select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,42,82,.12); }

/* flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 600; font-size: 14px; }
.flash-ok { background: #dcfce7; color: #166534; }
.flash-err { background: #fee2e2; color: #991b1b; }

/* trial banner (sidebar in lib.php + dashboard in index.php) */
.trial-banner { background: #fef3c7; color: #92400e; border: 1.5px solid #f59e0b;
  border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-weight: 700; font-size: 14px; }

/* POS */
.pos-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-cart { position: sticky; top: 16px; }
.pos-total { font-size: 26px; font-weight: 800; color: var(--primary); }
.pos-line { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid #e8edf2; }

/* receipt (A4 only — no thermal printing) */
.receipt { background: #fff; border-radius: 12px; padding: 28px 30px; box-shadow: 0 1px 4px rgba(16,24,40,.07); max-width: 720px; }
.receipt-head { text-align: center; border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: 14px; }
.receipt-head h1 { margin: 0; color: var(--primary); font-size: 22px; }
.receipt-tbl { width: 100%; border-collapse: collapse; margin: 12px 0; }
.receipt-tbl th { text-align: left; border-bottom: 1.5px solid #cbd5e1; padding: 6px 4px; font-size: 13px; }
.receipt-tbl td { padding: 6px 4px; border-bottom: 1px solid #e8edf2; font-size: 14px; }
.receipt-totals { margin-left: auto; width: 280px; }
/* Horizontal-scroll wrapper for the invoice table on small screens
   (sale.php wraps .receipt-tbl in this). */
.receipt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { padding: 0; }
  .receipt { box-shadow: none; border-radius: 0; max-width: none; }
}
