/* ============================================================
   Enterprise Retail Lease Management System
   Design system: petrol-blue + brass, ledger-inspired
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink:        #14232e;
  --ink-2:      #3d525f;
  --muted:      #6b8090;
  --line:       #dfe6ec;
  --line-2:     #eef2f5;
  --bg:         #eef1f4;
  --surface:    #ffffff;
  --surface-2:  #f7f9fb;

  --brand:      #123b4f;   /* deep petrol blue */
  --brand-2:    #1d5670;
  --brand-ink:  #0c2a38;
  --accent:     #b8802b;   /* brass */
  --accent-soft:#f4e9d5;

  --green:  #1e8e5a;  --green-bg:  #e4f4ec;
  --amber:  #b8802b;  --amber-bg:  #f8efdd;
  --red:    #c0392b;  --red-bg:    #fbe6e3;
  --blue:   #2b6ca3;  --blue-bg:   #e5eff6;
  --slate:  #64798a;  --slate-bg:  #eaeef2;
  --violet: #6b4f9e;  --violet-bg: #ede7f6;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20,35,46,.06), 0 3px 12px rgba(20,35,46,.05);
  --shadow-lg: 0 8px 30px rgba(20,35,46,.14);
  --sidebar-w: 244px;

  --tab-num: "tnum" 1, "lnum" 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.tnum { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- Layout shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--brand);
  color: #cfe0e8;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
  z-index: 40;
}
.brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .mark {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 19px;
  color: #fff;
  letter-spacing: -.01em;
  display: flex; align-items: center; gap: 9px;
}
.brand .mark .glyph {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent);
  color: var(--brand-ink);
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
  font-family: 'Inter', sans-serif;
}
.brand .sub { font-size: 11px; color: #8fb0bf; margin-top: 6px; letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: 10px 10px 20px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: #6f97a8; padding: 14px 12px 6px; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: 8px; margin: 1px 0;
  color: #bcd3dd; font-weight: 500; font-size: 13.5px;
  cursor: pointer; transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--brand-2); color: #fff; }
.nav a.active .ico { color: var(--accent); }
.nav a .ico { width: 17px; height: 17px; flex: 0 0 17px; color: #7ea6b7; }
.nav a.active .ico, .nav a:hover .ico { color: #cfe0e8; }

/* ---------- Main ---------- */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-weight: 600; font-size: 16px; color: var(--ink); }
.topbar .page-title small { display:block; font-weight:400; font-size:11.5px; color: var(--muted); margin-top:1px;}
.topbar .spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 11px; width: 280px;
}
.search input { border: 0; background: transparent; outline: none; font-size: 13px; width: 100%; color: var(--ink); font-family: inherit;}
.search svg { color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 6px; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.user-chip .u-name { font-size: 13px; font-weight: 600; }
.user-chip .u-role { font-size: 11px; color: var(--muted); }

.content { padding: 24px 26px 60px; max-width: 1360px; }

/* ---------- Generic bits ---------- */
.section-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 26px 0 12px; letter-spacing: .01em; }
.section-title:first-child { margin-top: 4px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mono-num { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- Cards & KPI ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi .label { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 8px; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .value.small { font-size: 21px; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi .foot b { color: var(--ink-2); font-weight: 600; }
.kpi .accent-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.kpi.brand .accent-bar { background: var(--brand-2); }
.kpi.green .accent-bar { background: var(--green); }
.kpi.red .accent-bar { background: var(--red); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line-2);
}
.panel-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.panel-head .hint { font-size: 12px; color: var(--muted); }
.panel-body { padding: 6px 0; }
.panel-body.pad { padding: 18px; }

.cols-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface-2);
}
table.grid td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover { background: var(--surface-2); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
table.grid td.strong { color: var(--ink); font-weight: 600; }
.lease-link { color: var(--brand-2); font-weight: 600; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; line-height: 1.4;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.green  { background: var(--green-bg);  color: var(--green); }
.pill.amber  { background: var(--amber-bg);  color: var(--amber); }
.pill.red    { background: var(--red-bg);    color: var(--red); }
.pill.blue   { background: var(--blue-bg);   color: var(--blue); }
.pill.slate  { background: var(--slate-bg);  color: var(--slate); }
.pill.violet { background: var(--violet-bg); color: var(--violet); }

/* ---------- Buttons / filters ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: all .12s; font-family: inherit;
}
.btn:hover { border-color: var(--brand-2); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-size: 13px; color: var(--ink); font-family: inherit; outline: none;
}
.filters select:focus, .filters input:focus { border-color: var(--brand-2); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--surface); font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--ink-2);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Charts (hand-rolled SVG/CSS) ---------- */
.bar-row { display: grid; grid-template-columns: 130px 1fr 96px; align-items: center; gap: 12px; padding: 7px 0; }
.bar-row .bl { font-size: 12.5px; color: var(--ink-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--line-2); height: 22px; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); border-radius: 5px; }
.bar-row .bv { text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 14px; }
.legend .li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* ---------- Lease detail ---------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.detail-head .lno { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.detail-head .subline { color: var(--muted); font-size: 13px; margin-top: 4px; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--brand-2); font-weight: 600; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }

.fact-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.fact { background: var(--surface); padding: 13px 16px; }
.fact .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.fact .v { font-size: 14px; color: var(--ink); font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 22px 0 0; flex-wrap: wrap; }
.tab { padding: 9px 15px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--brand); border-bottom-color: var(--accent); }
.tab-body { padding-top: 18px; }

.def-list { display: grid; grid-template-columns: 200px 1fr; gap: 0; }
.def-list .dt { padding: 11px 0; font-size: 12.5px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line-2); }
.def-list .dd { padding: 11px 0; font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--line-2); }

/* ---------- Misc ---------- */
.empty { padding: 40px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.loading { display: grid; place-items: center; padding: 80px; color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand-2); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert-tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.alert-30  { background: var(--red-bg); color: var(--red); }
.alert-60  { background: var(--amber-bg); color: var(--amber); }
.alert-90  { background: var(--blue-bg); color: var(--blue); }
.alert-120, .alert-180 { background: var(--slate-bg); color: var(--slate); }
.alert-Overdue { background: var(--red); color: #fff; }

.report-list { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.report-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: all .12s; box-shadow: var(--shadow);
}
.report-item:hover { border-color: var(--brand-2); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.report-item .ri-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.report-item .ri-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.report-item .ri-cat { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; }

.mini-stat { display: flex; align-items: baseline; gap: 8px; }
.mini-stat .n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-stat .l { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 9px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px); transition: all .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .fact-grid { grid-template-columns: repeat(2,1fr); }
  .report-list { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); width: 244px; flex-basis: 244px; }
  .main { margin-left: 0; }
  .menu-btn { display: grid !important; }
  .search { width: 150px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .fact-grid { grid-template-columns: 1fr; }
  .def-list { grid-template-columns: 1fr; }
  .def-list .dt { border-bottom: 0; padding-bottom: 0; }
}
.menu-btn { display: none; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); place-items: center; cursor: pointer; }

*:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
