:root {
  --bg: #07324c;
  --panel: #0c4568;
  --ink: #ffffff;
  --muted: #9ec4d8;
  --line: rgba(255,255,255,.10);
  --brand: #4aa7d4;
  --brand-2: #7dd3fc;
  --brand-dark: #083d5d;
  --accent: #f5d76e;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #34d399;
  --off: #94a3b8;
  --wa: #25d366;
  --shadow: 0 10px 28px rgba(0, 16, 28, .28);
  --radius: 18px;
  --sidebar: 292px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Cairo", var(--emoji), Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
.ico, .nav-ico, .stat-ico, .page-ico, .metric-ico, .bottom-nav a span {
  font-family: var(--emoji);
  font-style: normal;
  font-weight: 400;
  line-height: 1;
}
.ico { display: inline-block; vertical-align: middle; }

a { color: #7dd3fc; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4rem; color: #fff; font-weight: 800; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  background: #083d5d;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 18px 10px;
}
.logo {
  width: 52px; height: 52px; border-radius: 14px; overflow: hidden;
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-brand strong { font-size: 18px; }
.sidebar-brand small { display: block; color: #b7d4e6; font-size: 12px; font-weight: 400; }
.gen-state {
  margin: 12px 16px 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #062f4a;
  display: flex; align-items: center; gap: 10px;
  font-weight: 700;
}
.gen-state .dot { width: 10px; height: 10px; border-radius: 50%; background: #8aa4b5; }
.gen-state.on .dot { background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,.2); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(52,211,153,0); } }

.sidebar nav { padding: 4px 12px 12px; overflow: auto; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: #fff; padding: 11px 12px; border-radius: 14px;
  text-decoration: none; margin-bottom: 3px; font-weight: 700;
}
.sidebar nav a .ico { font-size: 22px; width: 1.5em; text-align: center; flex-shrink: 0; }
.page-ico .ico { font-size: 28px; }
.bottom-nav a .ico { display: block; font-size: 22px; margin-bottom: 2px; }
.sidebar nav a:hover { background: rgba(74,167,212,.22); text-decoration: none; }
.sidebar nav a.active { background: rgba(74,167,212,.38); }
.nav-label { color: #8eb8d0; font-size: 13px; margin: 14px 12px 6px; font-weight: 700; }
.badge {
  background: #ef4444; color: #fff; border-radius: 999px;
  min-width: 20px; height: 20px; font-size: 11px;
  display: inline-grid; place-items: center; padding: 0 6px; margin-right: auto;
}
.sidebar-user {
  padding: 14px 18px 18px; display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid rgba(255,255,255,.08); color: #c5e0ef; background: #062f4a;
}
.sidebar-user a { color: var(--accent); font-weight: 800; text-decoration: none; }

.main { flex: 1; min-width: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 22px 6px; }
.topbar h1 { font-size: 22px; flex: 1; display: flex; align-items: center; gap: 10px; }
.page-ico { font-size: 28px; }
.topbar-meta { color: var(--muted); }
.menu-btn {
  display: none; border: 0; background: var(--panel); color: #fff;
  width: 44px; height: 44px; border-radius: 14px; cursor: pointer; font-size: 20px;
}
.content { padding: 8px 22px 32px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2, .card h3 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .stat-ico { font-size: 26px; display: block; margin-bottom: 8px; }
.stat small { color: var(--muted); display: block; font-weight: 700; }
.stat strong { font-size: 24px; display: block; margin-top: 4px; color: #fff; }
.stat.ok strong, .stat.mint strong { color: var(--ok); }
.stat.warn strong, .stat.gold strong { color: var(--accent); }
.stat.danger strong, .stat.rose strong { color: #fca5a5; }
.stat.sky, .stat.gold, .stat.mint, .stat.rose { background: #0c4568; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }

.live-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.gauge-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.gauge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #062f4a;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px 10px 14px;
  min-height: 124px;
}
.gauge-row.bad { box-shadow: inset 0 0 0 2px rgba(248,113,113,.55); }
.gauge-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.gauge-ico { font-size: 28px; font-family: var(--emoji); }
.gauge-name { color: #9ec4d8; font-size: 14px; font-weight: 700; }
.gauge-read { font-size: 28px; font-weight: 800; color: #fff; line-height: 1.15; }
.gauge-read .unit { font-size: 14px; color: #b7d4e6; font-weight: 700; margin-right: 4px; }
.gauge-dial { width: 112px; height: 112px; flex-shrink: 0; }
.gauge-needle { transition: transform .45s ease; }

.metric {
  background: #062f4a;
  color: #fff;
  border-radius: 18px;
  padding: 16px;
  min-height: 118px;
  border: 1px solid var(--line);
}
.metric-ico { font-size: 22px; display: block; margin-bottom: 6px; }
.metric label { color: #9ec4d8; font-size: 13px; font-weight: 700; }
.metric .val { font-size: 28px; font-weight: 800; margin-top: 8px; }
.metric .unit { font-size: 14px; color: #b7d4e6; }
.metric.good { box-shadow: inset 0 0 0 2px rgba(52,211,153,.45); }
.metric.bad { box-shadow: inset 0 0 0 2px rgba(248,113,113,.65); }
.status-big { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; }
.status-big .lamp { width: 16px; height: 16px; border-radius: 50%; background: #8aa4b5; }
.status-big.on .lamp { background: #34d399; box-shadow: 0 0 16px #34d399; }
.status-big.off .lamp { background: #8aa4b5; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 11px 8px; border-bottom: 1px solid var(--line); font-size: 14px; color: #e8f6ff; }
th { color: var(--muted); font-weight: 700; background: #062f4a; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; border-radius: 14px; padding: 11px 16px; cursor: pointer;
  font-family: inherit; font-weight: 800; text-decoration: none;
  min-height: 44px; color: #fff;
}
.btn:hover { text-decoration: none; opacity: .94; }
.btn-primary { background: #4aa7d4; color: #fff; }
.btn-accent { background: var(--accent); color: #1b1403; }
.btn-danger { background: #e11d48; color: #fff; }
.btn-ghost { background: #062f4a; color: #fff; border: 1px solid var(--line); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 38px; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
label, .field { display: grid; gap: 6px; font-weight: 700; color: #d7eefb; font-size: 14px; }
.field-label { color: #e8f6ff; }
.field-control { position: relative; display: block; }
.field-ico { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-family: var(--emoji); font-size: 18px; pointer-events: none; z-index: 0; }
.field-control input:not([type=checkbox]):not([type=radio]), .field-control select, .field-control textarea { width: 100%; padding-right: 42px; position: relative; z-index: 1; }
input, select, textarea {
  font-family: inherit; font-size: 16px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: #062f4a; color: #fff; width: 100%;
  -webkit-user-select: text; user-select: text;
  pointer-events: auto !important; opacity: 1; touch-action: manipulation;
  caret-color: #fff;
}
input::placeholder, textarea::placeholder { color: #7fa3b8; }
option { background: #083d5d; color: #fff; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(74,167,212,.35);
  border-color: #4aa7d4;
}
textarea { min-height: 90px; resize: vertical; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.muted { color: var(--muted); }
.alert { padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; }
.alert-success { background: rgba(52,211,153,.18); color: #bbf7d0; }
.alert-danger { background: rgba(248,113,113,.18); color: #fecaca; }
.alert-warning { background: rgba(251,191,36,.16); color: #fde68a; }
.alert-info { background: rgba(74,167,212,.18); color: #bae6fd; }

.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill-ok { background: rgba(52,211,153,.2); color: #6ee7b7; }
.pill-warn { background: rgba(251,191,36,.2); color: #fde68a; }
.pill-danger { background: rgba(248,113,113,.2); color: #fca5a5; }
.pill-off { background: rgba(148,163,184,.2); color: #cbd5e1; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { min-width: 160px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  border: 1px solid var(--line); background: #062f4a; color: #fff; border-radius: 999px;
  padding: 8px 12px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 13px;
}
.chip:hover, .chip.active { background: rgba(74,167,212,.38); border-color: #4aa7d4; }

.live-quote {
  background: rgba(74,167,212,.28);
  color: #fff; border-radius: 18px; padding: 14px 16px; font-weight: 800;
}

.auth-body {
  min-height: 100vh;
  display: grid; place-items: center;
  background: #083d5d;
  padding: 20px;
}
.auth-card {
  width: min(440px, 100%);
  background: #0c4568; color: #fff; border-radius: 28px; padding: 26px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.auth-card h1 { color: #fff; }
.install-card { width: min(640px, 100%); }
.brand-mark {
  width: 64px; height: 64px; border-radius: 18px; overflow: hidden;
  display: grid; place-items: center; margin-bottom: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.auth-tabs a, .auth-tabs button {
  text-align: center; padding: 10px; border-radius: 14px; background: #062f4a;
  color: #fff; font-weight: 800; border: 0; font-family: inherit; cursor: pointer;
  text-decoration: none;
}
.auth-tabs .on { background: rgba(74,167,212,.45); }

.print-sheet { max-width: 800px; margin: 24px auto; background: #fff; color: #0f2740; padding: 28px; }
.print-sheet h1, .print-sheet h2 { color: #0f2740; }
.print-head { display: flex; justify-content: space-between; border-bottom: 2px solid #083d5d; padding-bottom: 12px; margin-bottom: 18px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,16,28,.55); z-index: 15; }
.overlay.show { display: block; }

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
  background: #083d5d; color: #fff;
  padding: 8px 6px calc(8px + var(--safe-bottom));
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.25);
}
.bottom-nav a {
  color: #b7d4e6; text-decoration: none; text-align: center; font-size: 11px; font-weight: 700;
  padding: 6px 2px; border-radius: 12px;
}
.bottom-nav a span { display: block; font-size: 22px; }
.bottom-nav a.active { color: #fff; background: rgba(74,167,212,.38); }

.gen-art { width: 100%; max-width: 280px; margin: 0 auto; display: block; }
.gen-art .fan { transform-origin: 86px 72px; }
.gen-art.on .fan { animation: spin 1.1s linear infinite; }
.gen-art.on .glow { opacity: 1; }
.gen-art .glow { opacity: .25; transition: .3s; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero-run {
  display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center;
  background: #0c4568; color: #fff; border-radius: 22px; padding: 16px;
  margin-bottom: 16px; border: 1px solid var(--line);
}
.hero-run.off { background: #0c4568; }
.hero-run h2 { margin: 0; font-size: 26px; }
.amp-bar { height: 12px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.amp-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.receipt {
  max-width: 520px; margin: 0 auto; background: #0c4568; color: #fff;
  border-radius: 24px; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.receipt-top { background: #083d5d; color: #fff; padding: 22px; text-align: center; }
.receipt-body { padding: 18px 20px 24px; }
.receipt-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); color: #e8f6ff; }
.receipt-total { font-size: 28px; font-weight: 800; text-align: center; margin: 14px 0; color: var(--accent); }

.portal-body { background: var(--bg); color: #fff; min-height: 100vh; padding-bottom: 86px; }
.portal-wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.portal-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.p-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 16px; margin-bottom: 12px; }
.p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.p-stat { background: #062f4a; border-radius: 18px; padding: 14px; border: 1px solid var(--line); }
.p-stat small { color: var(--muted); display: block; font-weight: 700; }
.p-stat strong { font-size: 22px; display: block; }
.portal-body a { color: #7dd3fc; }
.notice { font-size: 13px; color: var(--muted); margin: 0; }

code { color: var(--accent); }

@media (max-width: 1100px) {
  .grid-4, .kpi-row, .live-grid, .gauge-board { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; right: 0; transform: translateX(110%); z-index: 20; transition: .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; }
  .grid-2, .form-grid.two, .grid-3, .grid-4, .kpi-row, .live-grid, .gauge-board { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .content, .topbar { padding-right: 14px; padding-left: 14px; }
  .content { padding-bottom: 96px; }
  .topbar-meta { display: none; }
  .bottom-nav { display: grid; }
  .hero-run { grid-template-columns: 110px 1fr; }
  th, td { font-size: 13px; white-space: nowrap; }
}
@media print {
  .sidebar, .topbar, .btn, .toolbar, .bottom-nav, .overlay { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body, .receipt, .receipt-body, .receipt-row { background: #fff !important; color: #111 !important; }
  .receipt-top { background: #083d5d !important; color: #fff !important; }
}
