/* SERVADMIN design system — lifted from the original static dashboard. */
:root {
  --accent: #0e5a43;
  --accent-hover: #0a4232;
  --accent-tint: #e6f0ec;
  --bg: #f5f4f1;
  --surface: #ffffff;
  --border: #e7e3db;
  --text: #1c1917;
  --text-2: #57534e;
  --muted: #78716c;
  --faint: #a8a29e;
  --amber: #e0a53a;
  --orange: #d98a2b;
  --amber-dark: #b45309;
  --red: #b1442f;
  --blue: #3457b3;
  --blue-tint: #eef2fb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d6d3cd; border-radius: 8px; border: 2px solid var(--bg); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- App shell ---- */
.sa-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.sa-header {
  flex: 0 0 auto; height: 66px; display: flex; align-items: center; gap: 20px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.sa-body { display: flex; flex: 1; min-height: 0; }
.sa-nav {
  flex: 0 0 236px; background: var(--surface); border-inline-end: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.sa-main { flex: 1; overflow-y: auto; padding: 26px 30px; }

/* ---- Header ---- */
.sa-brand { display: flex; align-items: center; gap: 12px; }
.sa-logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 17px;
}
.sa-brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.3px; line-height: 1.1; }
.sa-brand-tag { font-size: 11px; color: var(--muted); line-height: 1.1; }
.sa-search {
  display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 13px; flex: 1; max-width: 420px;
}
.sa-search input { border: none; outline: none; background: transparent; font-family: inherit; font-size: 13px; width: 100%; color: var(--text); }
.sa-spacer { flex: 1; }
.sa-langbtn {
  display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 13px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text);
}
.sa-langbtn:hover { border-color: var(--accent); color: var(--accent); }
.sa-hdivider { width: 1px; height: 26px; background: var(--border); }
.sa-user { display: flex; align-items: center; gap: 10px; }
.sa-user-name { font-size: 13px; font-weight: 600; }
.sa-user-role { font-size: 11px; color: var(--muted); }
.sa-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-tint); color: var(--accent);
  font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center;
}

/* ---- Sidebar ---- */
.sa-nav-label { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.6px; padding: 8px 12px 6px; }
.sa-nav-btn {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px; border: none;
  font-family: inherit; font-size: 13.5px; cursor: pointer; text-align: start; width: 100%;
  background: transparent; font-weight: 500; color: var(--text-2); text-decoration: none;
}
.sa-nav-btn:hover { background: var(--bg); color: var(--text-2); }
.sa-nav-btn.active { background: var(--accent-tint); font-weight: 600; color: var(--accent); }
.sa-nav-btn.active:hover { color: var(--accent); }
.sa-badge { margin-inline-start: auto; font-size: 11px; font-weight: 600; color: var(--faint); background: #f0eee9; padding: 1px 8px; border-radius: 20px; }
.sa-portfolio { margin-top: auto; padding: 14px 12px; background: var(--bg); border-radius: 12px; }
.sa-portfolio-title { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.sa-portfolio-num { font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1; }
.sa-portfolio-cap { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---- Page header ---- */
.sa-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.sa-page-head h1 { margin: 0; font-size: 23px; font-weight: 700; }
.sa-page-head p { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.sa-updated { font-size: 12px; color: var(--faint); }
.sa-back {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  cursor: pointer; color: var(--text-2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.sa-back:hover { border-color: var(--accent); color: var(--accent); }
html[dir="rtl"] .sa-back svg { transform: scaleX(-1); }

/* ---- Cards & grids ---- */
.sa-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.sa-card--flush { padding: 0; overflow: hidden; }
.sa-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid #eee9e1; }
.sa-card-title { font-size: 15px; font-weight: 600; }
.sa-card-sub { font-size: 12px; color: var(--muted); }
.sa-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.sa-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.sa-row { display: grid; gap: 16px; margin-bottom: 18px; }
.sa-row--wide { grid-template-columns: 1.7fr 1fr; }
@media (max-width: 1100px) { .sa-grid-4 { grid-template-columns: repeat(2, 1fr); } .sa-row--wide, .sa-grid-2 { grid-template-columns: 1fr; } }

/* ---- KPI cards ---- */
.sa-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.sa-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sa-kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.sa-kpi-delta { font-size: 11px; font-weight: 600; }
.sa-kpi-value { font-size: 27px; font-weight: 700; margin-top: 10px; line-height: 1; color: var(--text); }
.sa-kpi-sub { font-size: 12px; color: var(--faint); margin-top: 6px; }
.sa-kpi--bordered { border-top: 3px solid var(--accent); }

/* ---- Charts ---- */
.sa-bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 6px; }
.sa-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 7px; }
.sa-bar { width: 100%; border-radius: 6px 6px 0 0; min-height: 3px; transition: height .4s; }
.sa-bar-label { font-size: 10px; color: var(--faint); }
.sa-track { display: flex; height: 12px; border-radius: 7px; overflow: hidden; background: #f0eee9; }
.sa-track > span { height: 100%; }
.sa-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sa-legend-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.sa-legend-left { display: flex; align-items: center; gap: 8px; color: var(--text-2); }

/* ---- Tables ---- */
.sa-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sa-table thead th {
  color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 600; padding: 10px 20px; text-align: start; white-space: nowrap;
}
.sa-table--list thead th { background: #faf9f6; }
.sa-table tbody td { padding: 12px 20px; border-top: 1px solid #f0ede6; vertical-align: middle; }
.sa-table tbody tr.clickable { cursor: pointer; }
.sa-table tbody tr.clickable:hover { background: #faf8f4; }
.sa-th-c, .sa-td-c { text-align: center; }
.sa-th-e, .sa-td-e { text-align: end; }
.sa-cell-name { font-weight: 600; color: var(--text); }
.sa-cell-sub { font-size: 11px; color: var(--faint); }
.sa-cell-muted { color: var(--text-2); }
.sa-money-pos { color: var(--accent); font-weight: 600; }
.sa-money-neg { color: var(--red); font-weight: 600; }
.sa-truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-empty { padding: 30px 20px; text-align: center; color: var(--faint); font-size: 13px; }

/* ---- Pills, chips, buttons ---- */
.sa-pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.sa-pill--active { background: #e6f0ec; color: #0e5a43; }
.sa-pill--expiring { background: #fbeed9; color: #b45309; }
.sa-pill--expired { background: #f7e4e0; color: #b1442f; }
.sa-pill--site { background: #e6f0ec; color: #0e5a43; }
.sa-pill--tenant { background: #eef2fb; color: #3457b3; }
.sa-pill--pending { background: #f0eee9; color: #78716c; }
.sa-pill--parsed { background: #e6f0ec; color: #0e5a43; }
.sa-pill--processing { background: #fbeed9; color: #b45309; }
.sa-pill--failed { background: #f7e4e0; color: #b1442f; }
.sa-chip { font-size: 12px; font-weight: 600; padding: 6px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap; background: var(--bg); color: var(--text-2); border: none; }
.sa-chip.active { background: var(--accent); color: #fff; }
.sa-filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.sa-btn { display: inline-flex; align-items: center; gap: 7px; font-family: inherit; font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: 9px; cursor: pointer; border: 1px solid var(--border); background: #fff; color: var(--text); }
.sa-btn:hover { border-color: var(--accent); color: var(--accent); }
.sa-btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.sa-btn--primary:hover { background: var(--accent-hover); color: #fff; }
.sa-btn--sm { padding: 6px 12px; font-size: 12px; }

/* ---- Key/value rows ---- */
.sa-kv { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; padding: 7px 0; }
.sa-kv + .sa-kv { border-top: 1px solid #f0ede6; }
.sa-kv .k { color: var(--muted); }
.sa-kv .v { font-weight: 600; text-align: end; }

/* ---- Forms ---- */
.sa-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.sa-field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.sa-input, .sa-select, .sa-textarea {
  font-family: inherit; font-size: 13px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 9px; background: #fff; color: var(--text); width: 100%;
}
.sa-input:focus, .sa-select:focus, .sa-textarea:focus { outline: none; border-color: var(--accent); }
.sa-error { color: var(--red); font-size: 11px; }

/* ---- Auth ---- */
.sa-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.sa-auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; }
.sa-auth-logo { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; margin-bottom: 18px; }

/* ---- Cashflow grid (Excel-style) ---- */
.cf-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cf-wrap { border: 1px solid #b9bec9; border-radius: 4px; overflow-x: auto; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.cf-table { border-collapse: collapse; font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; width: 100%; min-width: 1100px; }
.cf-table th, .cf-table td { padding: 5px 10px; border-inline-start: 1px solid #e6e2d9; border-bottom: 1px dotted #ddd8ce; }
.cf-section td { background: #dbe4f2; font-weight: 800; color: #2e5fa3; letter-spacing: 0.4px; border-bottom: 1px solid #b9bec9; }
.cf-yearband th { background: #4472c4; color: #fff; font-weight: 700; text-align: end; }
.cf-yearband th.cf-name { text-align: start; }
.cf-yearband th.cf-total { background: #345aa8; }
.cf-name { text-align: start; position: sticky; inset-inline-start: 0; background: #fff; z-index: 1; min-width: 220px; }
.cf-num { text-align: end; color: #292524; }
.cf-total { background: #f3f0e8; font-weight: 700; }
.cf-loc td { font-weight: 600; color: #1c1917; cursor: pointer; }
.cf-loc:hover td.cf-name { background: #f6f8fc; }
.cf-tenant td { background: #fcfbf8; color: #57534e; font-size: 11px; }
.cf-tenant td.cf-name { padding-inline-start: 30px; background: #fcfbf8; }
.cf-tenant:hover td { background: #f6f4ee; }
.cf-caret { display: inline-block; width: 10px; color: #78716c; transition: transform .15s; }
.cf-caret.open { transform: rotate(90deg); }
html[dir="rtl"] .cf-caret { transform: scaleX(-1); }
html[dir="rtl"] .cf-caret.open { transform: rotate(90deg); }
.cf-summary td { font-weight: 700; border-top: 2px solid #1c1917; }
.cf-summary td.cf-total { background: #e4dfd3; }
.cf-cumulative td { background: #fbf3f2; font-weight: 800; }
.cf-cumulative td.cf-name { background: #fbf3f2; }
.cf-neg { color: #c0392b; }

/* ---- Alerts (renewals) ---- */
.sa-alert { padding: 11px 12px; background: #faf8f4; border: 1px solid #eee9e1; border-radius: 10px; display: flex; align-items: center; gap: 11px; }
.sa-alert:hover { border-color: #d8d2c6; }
.sa-alert-accent { width: 4px; align-self: stretch; border-radius: 3px; flex: 0 0 4px; }
.sa-alert-body { flex: 1; }
.sa-alert-name { font-size: 13px; font-weight: 600; }
.sa-alert-site { font-size: 11px; color: var(--faint); }
.sa-stack { display: flex; flex-direction: column; gap: 8px; }
