/* Eco Solutions — Admin dashboard
   Modern light shell with a dark map panel. Sidebar + KPI cards + charts. */

:root {
  --eco-900: #062b4f;
  --eco-700: #0a4d8c;
  --eco-600: #0b5aa3;
  --eco-500: #1574d4;
  --eco-400: #2e9be6;
  --accent: #34d399;
  --amber: #f59e0b;
  --red: #ef4444;
  --ink: #0c2236;
  --ink-soft: #5a7388;
  --ink-faint: #8aa0b2;
  --bg: #eef3f8;
  --panel: #ffffff;
  --line: #e4ecf3;
  --radius: 18px;
  --shadow: 0 12px 34px -20px rgba(6, 43, 79, 0.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(120% 80% at 80% -10%, #5bc6ea 0%, transparent 55%),
    radial-gradient(120% 90% at -10% 110%, #34d399 0%, transparent 45%),
    linear-gradient(160deg, var(--eco-900) 0%, var(--eco-700) 45%, var(--eco-500) 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 22px; padding: 30px;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.5);
}
.login-card .logo { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 26px; background: linear-gradient(150deg, var(--eco-500), var(--eco-700)); color: #fff; margin-bottom: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 23px; }
.login-card p { margin: 0 0 22px; color: var(--ink-soft); font-size: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%; font: inherit; font-size: 15px; padding: 12px 13px; border: 1.5px solid var(--line);
  border-radius: 11px; outline: none; transition: border-color .15s, box-shadow .15s; background: #fff; color: var(--ink);
}
.input:focus { border-color: var(--eco-400); box-shadow: 0 0 0 4px rgba(46,155,230,.15); }
.btn {
  font: inherit; font-size: 14.5px; font-weight: 650; cursor: pointer; border: none; border-radius: 11px;
  padding: 12px 16px; color: #fff; background: linear-gradient(135deg, var(--eco-500), var(--eco-700));
  box-shadow: 0 12px 26px -12px rgba(10,77,140,.8);
}
.btn.full { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: #fff; color: var(--eco-700); border: 1.5px solid var(--line); box-shadow: none; }
.btn:active { transform: translateY(1px); }
.alert { border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px; }
.alert.error { background: #fdecec; color: #b3261e; border: 1px solid #f7c9c5; }

/* ---------- App shell ---------- */
.shell { display: none; min-height: 100vh; grid-template-columns: 248px 1fr; }
.shell.active { display: grid; }

.sidebar {
  background: linear-gradient(180deg, var(--eco-900), var(--eco-700));
  color: #dbeafe; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; font-weight: 700; font-size: 16px; color: #fff; }
.sidebar .brand .logo { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; background: rgba(255,255,255,.14); }
.navitem {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 12px; cursor: pointer;
  color: #c5dbf2; font-size: 14.5px; font-weight: 550; transition: background .15s, color .15s; border: none; background: none; width: 100%; text-align: left;
}
.navitem .ic { font-size: 18px; width: 22px; text-align: center; }
.navitem:hover { background: rgba(255,255,255,.08); color: #fff; }
.navitem.active { background: rgba(255,255,255,.16); color: #fff; }
.sidebar .grow { flex: 1; }
.sidebar .userbox { font-size: 12.5px; color: #9fc1e6; padding: 12px 13px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar .userbox strong { color: #fff; display: block; font-size: 13.5px; }

.main { padding: 26px 30px 60px; overflow-x: hidden; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
.head-actions { display: flex; gap: 10px; align-items: center; }

.view { display: none; }
.view.active { display: block; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .label .dot { width: 9px; height: 9px; border-radius: 50%; }
.kpi .value { font-size: 32px; font-weight: 750; letter-spacing: -.02em; margin-top: 8px; }
.kpi .delta { font-size: 12.5px; margin-top: 4px; color: var(--ink-faint); }
.kpi .delta.up { color: #0f9d58; } .kpi .delta.down { color: var(--red); }

/* ---------- Panels / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1.4fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 2px; font-size: 15px; }
.panel .sub { color: var(--ink-soft); font-size: 12.5px; margin: 0 0 14px; }
.panel.map { padding: 0; overflow: hidden; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 20px; }
.filters .fld { display: flex; flex-direction: column; gap: 5px; }
.filters .fld label { font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.filters .input, .filters select { padding: 9px 11px; font-size: 13.5px; min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }
.filters .spacer { flex: 1; }

/* ---------- Map ---------- */
#map { width: 100%; height: 420px; }
.map-legend { position: absolute; left: 14px; bottom: 14px; background: rgba(6,43,79,.82); color: #fff; border-radius: 12px; padding: 10px 13px; font-size: 11.5px; backdrop-filter: blur(6px); z-index: 5; }
.map-legend .bar { height: 8px; width: 150px; border-radius: 5px; margin: 7px 0 4px; background: linear-gradient(90deg, #2e9be6, #34d399, #f59e0b, #ef4444); }
.map-legend .ends { display: flex; justify-content: space-between; opacity: .85; }
.map-head { position: absolute; left: 14px; top: 14px; z-index: 5; color: #fff; }
.map-head h3 { margin: 0; font-size: 15px; text-shadow: 0 1px 6px rgba(0,0,0,.5); }
.map-head p { margin: 2px 0 0; font-size: 12px; opacity: .85; text-shadow: 0 1px 6px rgba(0,0,0,.6); }

/* ---------- Table ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; padding: 13px 14px; background: #f7fafd; color: var(--ink-soft); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; white-space: nowrap; cursor: pointer; user-select: none; border-bottom: 1px solid var(--line); }
thead th .arrow { opacity: .4; font-size: 10px; }
thead th.sorted .arrow { opacity: 1; color: var(--eco-500); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: #f6fbff; }
tbody tr:last-child td { border-bottom: none; }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: #eef3f8; cursor: pointer; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.pill.eco { background: rgba(52,211,153,.16); color: #0f8a5f; }
.pill.gray { background: #eef2f6; color: var(--ink-soft); }
.muted { color: var(--ink-faint); }
.empty { padding: 50px 20px; text-align: center; color: var(--ink-faint); }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Maintenance ---------- */
.matrix td .sym { font-weight: 600; }
.zone-card { display: flex; gap: 12px; align-items: flex-start; }
.zone-card .ic { font-size: 22px; }
.legend-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; }
.legend-row .sw { width: 11px; height: 11px; border-radius: 3px; }
.demo-flag { display: inline-block; background: rgba(245,158,11,.15); color: #a16207; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; letter-spacing: .03em; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; }

/* ---------- Modal ---------- */
.modal-veil { position: fixed; inset: 0; background: rgba(6,43,79,.55); backdrop-filter: blur(4px); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-veil.show { display: grid; }
.modal { background: #fff; border-radius: 18px; max-width: 560px; width: 100%; max-height: 88vh; overflow: auto; box-shadow: 0 40px 90px -30px rgba(0,0,0,.6); }
.modal .mhead { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal .mhead h3 { margin: 0; font-size: 16px; }
.modal .x { border: none; background: #eef2f6; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.modal .mbody { padding: 18px 20px; }
.modal .photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.modal .photos figure { margin: 0; }
.modal .photos img { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #eef3f8; min-height: 120px; }
.modal .photos figcaption { font-size: 11.5px; color: var(--ink-soft); margin-top: 5px; text-align: center; }
.kv2 { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv2 .k { color: var(--ink-soft); }
.kv2 .v { font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: .25s; z-index: 120; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 980px) {
  .shell.active { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar .grow, .sidebar .userbox { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}
