/* ==========================================================================
   MOP — Admin dashboard theme
   Signature luxury palette from moptheme.pdf / mopwallpaper.JPG:
   obsidian black · warm taupe/greige · platinum · white. Editorial, restrained.
   ========================================================================== */
:root {
  --black:      #0B0B0C;   /* deepest ground */
  --panel:      #141412;   /* raised card */
  --panel-2:    #1B1A17;   /* nested / hover */
  --line:       rgba(233,229,218,0.10);
  --line-soft:  rgba(233,229,218,0.06);

  --taupe:      #A6A093;   /* signature greige */
  --taupe-dim:  #7C776B;
  --sand:       #C9C3B4;
  --platinum-1: #E7E3DB;
  --platinum-2: #9A948700;

  --white:      #F5F4F1;
  --text:       #EAE7E0;
  --muted:      #9C978B;
  --faint:      #6A655B;

  --canvas:     #F7F6F2;   /* light main-content background (behind the dark cards) */
  --ink:        #1A1815;   /* dark text for use ON the light canvas */
  --ink-soft:   #6E6A60;

  --good:       #86A98C;   /* muted sage */
  --warn:       #C8A657;   /* brass */
  --danger:     #C0705A;   /* terracotta */

  --radius: 16px;
  --radius-sm: 11px;
  --gap: 22px;
  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 24px 60px -30px rgba(0,0,0,0.85);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--black);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
}
/* faint brand glow + M watermark on the whole page */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1100px 700px at 82% -10%, rgba(166,160,147,0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(166,160,147,0.06), transparent 55%);
}
a { color: inherit; text-decoration: none; }

.eyebrow {
  font-size: 10.5px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--taupe-dim); font-weight: 700;
}
.mono-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---- Brand wordmark ---- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 26px; width: auto; display: block; opacity: 0.96; }
.brand .divider { width: 1px; height: 22px; background: var(--line); }
.brand .kicker { font-size: 11px; letter-spacing: 4px; text-transform: uppercase; color: var(--taupe); font-weight: 600; }

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr;
}
.login-hero {
  position: relative; overflow: hidden;
  background: #17150F center/cover no-repeat;
  border-right: 1px solid var(--line);
}
.login-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.login-hero::after { content:""; position:absolute; inset:0; background: linear-gradient(180deg, rgba(11,11,12,0.35), rgba(11,11,12,0.85)); }
.login-hero .hero-cap {
  position: absolute; left: 44px; bottom: 44px; z-index: 2; max-width: 70%;
}
.login-hero .hero-cap h1 { font-weight: 300; font-size: 34px; line-height: 1.15; margin: 14px 0 8px; color: var(--white); letter-spacing: 0.3px; }
.login-hero .hero-cap p { color: var(--taupe); margin: 0; font-size: 14px; letter-spacing: 0.4px; }

.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(380px, 92vw); }
.login-card h2 { font-weight: 300; font-size: 27px; margin: 18px 0 6px; color: var(--white); }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 26px; }
.field { position: relative; margin-bottom: 16px; }
.field input {
  width: 100%; padding: 15px 16px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--line); color: var(--white);
  font-family: var(--sans); font-size: 15.5px; letter-spacing: .3px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { letter-spacing: .3px; color: var(--faint); }
.field input:focus { border-color: var(--taupe); box-shadow: 0 0 0 3px rgba(166,160,147,0.12); }
.btn {
  width: 100%; padding: 15px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; font-family: var(--sans); font-size: 14px;
  font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  background: linear-gradient(180deg, #EFEBE2, #BFB9AC); color: #16150F;
  transition: transform .06s ease, filter .2s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.hidden { display: none !important; }

.sidebar {
  border-right: 1px solid var(--line); padding: 26px 18px; display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, rgba(20,20,18,0.6), rgba(11,11,12,0.2));
}
.sidebar .brand { padding: 0 8px 20px; margin-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 11px;
  color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 500; letter-spacing: .3px;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; opacity: .8; flex: none; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--white); }
.nav-item.active svg { opacity: 1; }
.sidebar .spacer { flex: 1; }
.who { padding: 12px 14px; border-top: 1px solid var(--line-soft); }
.who .name { color: var(--white); font-size: 14px; font-weight: 600; }
.who .role { font-size: 10.5px; letter-spacing: 2px; text-transform: uppercase; color: var(--taupe-dim); margin-top: 3px; }
.logout { margin-top: 10px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--faint); cursor: pointer; }
.logout:hover { color: var(--danger); }

.main { padding: 30px 34px 60px; min-width: 0; background: var(--canvas); }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.topbar h1 { font-weight: 300; font-size: 30px; margin: 6px 0 0; color: var(--ink); letter-spacing: .3px; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.select, .rangebtn {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-family: var(--sans); font-size: 13px; cursor: pointer;
  outline: none; transition: border-color .15s;
}
.select:hover, .rangebtn:hover { border-color: var(--taupe-dim); }
.rangebtn.active { background: var(--panel-2); border-color: var(--taupe); color: var(--white); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg .rangebtn { border: none; border-radius: 0; border-right: 1px solid var(--line); }
.seg .rangebtn:last-child { border-right: none; }

/* ---- KPI cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.kpi-grid.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid.kpi-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1050px) { .kpi-grid.kpi-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px)  { .kpi-grid.kpi-3, .kpi-grid.kpi-2 { grid-template-columns: 1fr; } }
.card {
  background: linear-gradient(180deg, var(--panel), #101010);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 10.5px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--taupe-dim); font-weight: 700; }
.kpi .value { font-weight: 300; font-size: 34px; color: var(--white); margin-top: 14px; letter-spacing: .5px; }
.kpi .value .unit { font-size: 14px; color: var(--taupe); margin-left: 6px; letter-spacing: 1px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 8px; }
.kpi .sub .up { color: var(--good); }
.kpi .sub .down { color: var(--danger); }
.kpi .accent { height: 2px; width: 34px; margin-top: 16px; background: linear-gradient(90deg, var(--sand), transparent); border-radius: 2px; }
.kpi { position: relative; }
.kpi .ic { position: absolute; top: 16px; right: 16px; width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center; color: var(--taupe); background: rgba(233,229,218,0.05);
  border: 1px solid var(--line); }
.kpi .ic svg { width: 24px; height: 24px; }
.block-head h3 { display: flex; align-items: center; }
.block-head h3 .hi { display: inline-flex; margin-right: 10px; }
.block-head h3 .hi svg { width: 18px; height: 18px; }

/* ---- layout blocks ---- */
.row { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.row.c2 { grid-template-columns: 1.6fr 1fr; }
.row.c2b { grid-template-columns: 1fr 1fr; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.block-head h3 { margin: 0; font-weight: 500; font-size: 15px; color: var(--white); letter-spacing: .3px; }
.block-head .hint { font-size: 11px; color: var(--faint); letter-spacing: .3px; }

/* ---- charts ---- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.legend { display: flex; gap: 18px; margin-top: 12px; }
.legend span { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; font-size: 13.5px; }
th { font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--taupe-dim); font-weight: 700; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid var(--line-soft); color: var(--text); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rankcell { display: flex; align-items: center; gap: 12px; }
.rankcell .dot { width: 28px; height: 28px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--taupe); font-weight: 700; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; letter-spacing: .5px; border: 1px solid var(--line); color: var(--muted); }
.pill svg { width: 13px; height: 13px; }
.pill.good { color: var(--good); border-color: rgba(134,169,140,.4); }
.pill.warn { color: var(--warn); border-color: rgba(200,166,87,.4); }
.pill.danger { color: var(--danger); border-color: rgba(192,112,90,.4); }

/* meter bar inside cells */
.meter { height: 6px; border-radius: 4px; background: var(--panel-2); overflow: hidden; min-width: 80px; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--sand), var(--taupe-dim)); }

.empty { color: var(--faint); font-size: 13px; padding: 26px 4px; text-align: center; }
.loading { color: var(--taupe-dim); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; padding: 40px; text-align: center; }

/* ---- sub-tabs (Manage) ---- */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid rgba(26,24,21,0.14); }
.tab { padding: 11px 16px; cursor: pointer; color: var(--ink-soft); font-size: 14px; font-weight: 500;
       border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--taupe-dim); }

/* action buttons */
.btn-sm { padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel);
          color: var(--text); font-family: var(--sans); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.btn-sm:hover { border-color: var(--taupe-dim); background: var(--panel-2); }
.btn-sm.primary { background: linear-gradient(180deg,#EFEBE2,#BFB9AC); color: #16150F; border-color: transparent; font-weight: 700; }
.btn-ghost { padding: 12px 22px; border-radius: 11px; border: 1px solid var(--line); background: transparent;
             color: var(--muted); font-family: var(--sans); font-size: 14px; cursor: pointer; }
.btn-ghost:hover { color: var(--text); border-color: var(--taupe-dim); }
.rowbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.linkbtn { color: var(--taupe); cursor: pointer; font-size: 13px; font-weight: 600; }
.linkbtn:hover { color: var(--sand); text-decoration: underline; }
.muted-note { color: var(--faint); font-size: 12.5px; }

/* ---- modal ---- */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(6,6,7,0.72);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(460px, 96vw); background: linear-gradient(180deg, var(--panel), #101010);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-weight: 500; font-size: 17px; color: var(--white); }
.modal-x { background: none; border: none; color: var(--faint); font-size: 16px; cursor: pointer; }
.modal-x:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }

/* ---- form fields inside modal ---- */
.frm { display: flex; flex-direction: column; gap: 14px; }
.frm label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--taupe-dim); font-weight: 700; display: block; margin-bottom: 6px; }
.frm input[type=text], .frm input[type=tel], .frm input[type=number], .frm select, .frm textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--white); font-family: var(--sans); font-size: 14.5px; outline: none;
}
.frm input:focus, .frm select:focus, .frm textarea:focus { border-color: var(--taupe); }
.frm textarea { resize: vertical; min-height: 60px; }
.frm .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.frm .check { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 14px; cursor: pointer; }
.frm .check input { width: 16px; height: 16px; }
.loc-checks { display: flex; flex-direction: column; gap: 9px; margin-top: 8px; max-height: 190px; overflow-y: auto; padding: 2px; }

/* ---- responsive ---- */
@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .row.c2, .row.c2b { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }

  /* Sidebar becomes a sticky top bar: logo + icon-only nav + sign-out. */
  .sidebar {
    position: sticky; top: 0; z-index: 20; width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 9px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-right: none; border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(20,20,18,0.96), rgba(11,11,12,0.92));
  }
  .sidebar .brand { padding: 0 4px 0 0; margin: 0; border-bottom: none; flex: none; }
  .sidebar .brand .divider, .sidebar .brand .kicker { display: none; }
  .sidebar .spacer { display: none; }
  .nav-item { flex: none; padding: 9px 11px; gap: 0; border-radius: 10px; }
  .nav-item span { display: none; }               /* icon-only on mobile */
  .nav-item svg { width: 20px; height: 20px; }
  .who { flex: none; margin-left: auto; padding: 0 2px; border-top: none; }
  .who .name, .who .role { display: none; }
  .logout { margin: 0; white-space: nowrap; }

  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .main { padding: 20px 14px 50px; }
  .topbar h1 { font-size: 24px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .kpi .value { font-size: 28px; }
  .kpi .ic { width: 38px; height: 38px; }
  .kpi .ic svg { width: 20px; height: 20px; }

  /* Wide tables scroll horizontally inside their card instead of overflowing. */
  .card { overflow-x: auto; }
  table { min-width: 480px; }
  .tabs { overflow-x: auto; white-space: nowrap; }
  .tab { flex: none; }
}
@media (max-width: 430px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
