/* Gluv demo stylesheet.
   --brand / --brand-dark are overwritten at runtime from the company profile
   (app.js applyBrandColor), so every brand-coloured rule follows the setting.
   Layout uses logical properties throughout so the Arabic RTL flip is free. */

:root {
  --bg: #f2f5f9;
  --panel: #ffffff;
  --ink: #16212b;
  --muted: #6a7885;
  --line: #e2e8ef;
  --brand: #1f5fa8;
  --brand-dark: #184a83;
  --brand-wash: #eef4fb;
  --green: #0a7d54;
  --green-wash: #d9f5e8;
  --amber: #b6790a;
  --amber-wash: #fff3d6;
  --red: #c23d0a;
  --red-wash: #fde2d5;
  --purple: #6b3fa0;
  --purple-wash: #efe6fb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 40, 60, .07), 0 6px 20px rgba(20, 40, 60, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans Arabic", "Tahoma", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.3; }
h3 { margin: 18px 0 8px; font-size: 14px; }
p { margin: 0 0 10px; }
.boot { padding: 48px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tight { margin: 0; }
.good-note { color: var(--green); font-weight: 600; }
.bad-note { color: var(--red); font-weight: 600; }

/* ---- Login ---------------------------------------------------------------- */
.login {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  background: radial-gradient(1100px 460px at 50% -8%, rgba(31, 95, 168, .18), transparent), var(--bg);
}
.login-top { width: 100%; display: flex; justify-content: flex-end; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(440px, 100%);
  margin-top: 28px;
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.login-title { font-size: 26px; font-weight: 700; }
.login-sub { margin-bottom: 18px; }
.login-form { display: grid; gap: 14px; }
.login-form .btn { justify-self: start; min-width: 140px; }
.login-form [role=alert]:empty { display: none; }

.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 20px; color: #fff;
  background: var(--muted);
}
.avatar.partner { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.avatar.staff { background: linear-gradient(135deg, #7c8b99, #5b6874); }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }

/* ---- Topbar --------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 20px;
  position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 700;
  flex: none;
}
.logo-lg { width: 60px; height: 60px; border-radius: 15px; font-size: 30px; }
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.topbar-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-chip { display: flex; align-items: center; gap: 8px; padding-inline-end: 6px; }
.user-chip-name { font-weight: 600; }

/* ---- Layout --------------------------------------------------------------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100vh - 67px); }
.sidebar {
  background: var(--panel); border-inline-end: 1px solid var(--line);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 4px;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-weight: 500;
}
.nav-item:hover { background: var(--brand-wash); }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-badge {
  background: var(--red); color: #fff; border-radius: 20px;
  padding: 1px 8px; font-size: 11px; font-weight: 700; flex: none;
}
.nav-item.active .nav-badge { background: #fff; color: var(--red); }
.sidebar-foot { margin-top: auto; padding: 12px 14px 4px; border-top: 1px solid var(--line); }
.main { padding: 20px 24px; overflow-x: hidden; min-width: 0; }
.page-title { margin: 0 0 16px; font-size: 22px; }

/* ---- Cards ---------------------------------------------------------------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card-attention { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 95, 168, .12), var(--shadow); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 15px; }
.card-body { padding: 16px; }
.card-actions, .modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card-actions { padding: 12px 16px; border-top: 1px solid var(--line); background: #fafbfd; }
.modal-actions { margin-top: 14px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- KPIs ----------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); border-top: 3px solid var(--line);
}
.kpi.good { border-top-color: var(--green); }
.kpi.bad { border-top-color: var(--red); }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---- Charts --------------------------------------------------------------- */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chart-box { position: relative; height: 280px; }
.chart-fallback { padding: 24px; text-align: center; }

/* ---- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { background: #f5f8fc; color: var(--muted); font-weight: 600; }
.tbl tbody tr:hover { background: #f8fafd; }
.tbl tfoot th { background: var(--brand-wash); color: var(--ink); font-weight: 700; }
.tbl tr.pl-head td { background: #f5f8fc; font-weight: 700; }
.tbl tr.pl-sub td { font-weight: 700; border-top: 2px solid var(--line); }
.tbl tr.muted td { color: var(--muted); }

/* Enhanced data table (table.js) */
.dt { width: 100%; }
.dt-wrap { display: flex; flex-direction: column; gap: 10px; }
.dt-toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.dt-toolbar .inp { width: auto; min-width: 150px; }
.dt-search { min-width: 240px; }
th.dt-sortable { cursor: pointer; user-select: none; }
th.dt-sortable:hover { color: var(--brand); }
.dt-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dt-info { color: var(--muted); font-size: 12px; }
.dt-pager { display: flex; align-items: center; gap: 8px; }
.dt-pageno { font-size: 13px; color: var(--muted); }
.dt-empty { text-align: center; padding: 26px !important; }

/* ---- Buttons -------------------------------------------------------------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit; transition: .12s;
}
a.btn { display: inline-block; text-decoration: none; }
.btn:hover { background: #eff3f8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #f0c3ae; }
.btn.danger:hover { background: var(--red-wash); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: none; background: none; cursor: pointer; font-size: 16px; color: var(--muted); font-family: inherit; }
.burger { display: none; font-size: 20px; }

/* ---- Badges --------------------------------------------------------------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.b-grey { background: #eef1f5; color: #667585; }
.b-blue { background: #e2eeff; color: #1b5fd0; }
.b-amber { background: var(--amber-wash); color: var(--amber); }
.b-green { background: var(--green-wash); color: var(--green); }
.b-red { background: var(--red-wash); color: var(--red); }
.b-purple { background: var(--purple-wash); color: var(--purple); }

/* ---- Notes ---------------------------------------------------------------- */
.note {
  padding: 10px 14px; border-radius: 10px; margin-bottom: 14px;
  background: #eef1f5; color: var(--ink); border-inline-start: 4px solid var(--muted); font-size: 13px;
}
.note.info { background: var(--brand-wash); border-inline-start-color: var(--brand); }
.note.good { background: var(--green-wash); border-inline-start-color: var(--green); }
.note.warn { background: var(--amber-wash); border-inline-start-color: var(--amber); }
.note.bad { background: var(--red-wash); border-inline-start-color: var(--red); }

/* ---- Forms ---------------------------------------------------------------- */
.inp {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; width: 100%; color: inherit;
}
.inp:focus { outline: 2px solid rgba(31, 95, 168, .3); border-color: var(--brand); }
.inp-color { height: 38px; padding: 3px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field span { font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.two-col { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.three { grid-template-columns: repeat(3, 1fr); }
.totals { margin-top: 10px; padding: 10px 12px; background: #f5f8fc; border-radius: 8px; display: flex; gap: 20px; flex-wrap: wrap; }
.meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 42px; height: 24px; border-radius: 20px; background: #cdd6e0;
  position: relative; transition: .16s; flex: none;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: .16s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-label { font-weight: 600; }
.rule-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }

/* Segmented control (individual vs shared) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; background: #fff; padding: 7px 14px; cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); }
.seg-btn.active { background: var(--brand); color: #fff; font-weight: 600; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: none; background: none; padding: 9px 14px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* Period filter */
.period { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.period .inp { width: auto; min-width: 150px; }
.period-custom { display: flex; align-items: center; gap: 8px; }

/* ---- Shared expenses ------------------------------------------------------ */
.shared-box {
  background: var(--purple-wash); border: 1px solid #ddcdf2;
  border-radius: 10px; padding: 12px; margin-top: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.split-out { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0; }
.split-part {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd;
}
.split-part.me { border-color: var(--brand); background: var(--brand-wash); }

.req-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.req-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: #fff; box-shadow: var(--shadow); }
.req-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.req-title { font-weight: 700; font-size: 15px; }
.req-memo { color: var(--muted); font-size: 13px; }
.req-actions { margin-top: 12px; }

/* ---- Documents (printable invoice) ---------------------------------------- */
.doc { font-size: 13px; }
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.doc-meta { text-align: end; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.doc-totals { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; align-items: flex-end; }
.doc-grand { font-size: 16px; font-weight: 700; border-top: 2px solid var(--line); padding-top: 6px; margin-top: 4px; }

/* ---- Modal ---------------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 28, 40, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 96vw); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-wide { width: min(880px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }

/* ---- Toasts --------------------------------------------------------------- */
.toast-host { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #16212b; color: #fff; padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow); font-size: 13px; opacity: 0;
  transform: translateY(-8px); transition: .22s; max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.good { background: var(--green); }
.toast.bad { background: var(--red); }

/* ---- Tour ----------------------------------------------------------------- */
.tour-overlay { position: fixed; inset: 0; background: rgba(15, 28, 40, .45); z-index: 300; }
.tour-pop { position: fixed; width: 300px; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); padding: 16px; }
.tour-pop h3 { margin: 4px 0 6px; font-size: 15px; }
.tour-pop p { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.tour-actions { display: flex; justify-content: space-between; gap: 8px; }

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; position: relative; }
  .burger { display: inline-block; }
  .sidebar {
    position: fixed; inset-inline-start: 0; top: 0; bottom: 0; width: 236px;
    z-index: 60; transform: translateX(-110%); transition: transform .2s;
  }
  html[dir="rtl"] .sidebar { transform: translateX(110%); }
  .layout.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(15, 28, 40, .4); }
  .form-grid, .form-grid.three, .two-col, .three, .split-out { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .login-title { font-size: 22px; }
}
