:root {
  --navy: #071a31;
  --navy2: #0b3158;
  --blue: #1769e0;
  --blue2: #2d7df0;
  --cyan: #18c1eb;
  --ink: #10233a;
  --muted: #718399;
  --line: #dfe7ef;
  --bg: #f4f7fb;
  --card: #ffffff;
  --green: #14a56c;
  --greenbg: #eaf8f2;
  --red: #e24e60;
  --redbg: #fff1f3;
  --purple: #7f48d7;
  --orange: #ff8c2a;
  --shadow: 0 14px 34px rgba(19,51,82,.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI Variable", "Aptos", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #f8fbfe 0, #f4f7fb 45%, #eef3f8 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { text-decoration: none; color: inherit; }

.shell {
  width: min(1320px, calc(100% - 24px));
  margin: 0 auto;
  padding-bottom: 34px;
}

/* Header / nav */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  color: var(--navy);
}
.brand img { height: 28px; width: auto; }
.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a, .nav button {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--ink);
}
.nav a:hover, .nav a.active {
  background: #eef5ff;
  color: var(--blue);
}

/* Hero */
.hero {
  margin: 0 -12px 20px;
  min-height: 180px;
  color: #fff;
  background: radial-gradient(circle at 75% 65%, rgba(0,139,255,.30), transparent 27%),
              linear-gradient(115deg, #061326 0%, #072246 58%, #061326 100%);
  border-radius: 0 0 30px 30px;
  padding: 26px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.hero h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.03em; }
.hero p { margin: 0; color: #d9e5f1; font-size: 15px; max-width: 360px; }

/* Status pill */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(60,220,153,.28);
  background: rgba(10,53,54,.65);
  color: #64e0a7;
  font-size: 12px;
  font-weight: 800;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #34d391; box-shadow: 0 0 0 4px rgba(52,211,145,.10); }
.status.off { border-color: rgba(226,78,96,.35); background: rgba(80,20,30,.55); color: #ff9aa6; }
.status.off .status-dot { background: #e24e60; box-shadow: 0 0 0 4px rgba(226,78,96,.10); }
.status.warn { border-color: rgba(255,140,42,.35); background: rgba(80,40,10,.55); color: #ffd2a8; }
.status.warn .status-dot { background: #ff8c2a; }

/* Cards / metrics */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.metric { display: flex; align-items: center; gap: 14px; min-height: 110px; }
.metric-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 48px; font-size: 20px; }
.metric-icon.blue { background: #edf4ff; color: var(--blue); }
.metric-icon.green { background: #e9f8f1; color: var(--green); }
.metric-icon.purple { background: #f3edff; color: var(--purple); }
.metric-icon.orange { background: #fff3e8; color: var(--orange); }
.metric small { display: block; color: #526783; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px; }
.metric strong { display: block; font-size: 28px; letter-spacing: -.04em; line-height: 1; }
.metric span { display: block; color: #8290a0; font-size: 11px; margin-top: 6px; }

.card { margin-bottom: 18px; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 17px 20px; border-bottom: 1px solid #e7edf3;
}
.card-title { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 900; text-transform: uppercase; color: #17365a; }
.card-body { padding: 14px 20px; }

/* Buttons */
.btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #ccdff6;
  background: #f7fbff;
  color: #145bcb;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}
.btn:hover { background: #eef5ff; }
.btn.primary { background: linear-gradient(115deg, var(--blue), #0d57db); color: #fff; border-color: var(--blue); }
.btn.success { color: #0d7a4f; background: #e9f8f1; border-color: #b8ead3; }
.btn.danger { color: #d94255; background: #fff5f6; border-color: #ffd5dc; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 11px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: inline-flex; gap: 8px; }
input, select, textarea {
  height: 38px; border: 1px solid #d5e0eb; border-radius: 10px; padding: 0 12px;
  font-size: 13px; background: #fff; color: var(--ink);
}
textarea { height: auto; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,224,.08); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 10px; text-align: left; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
th { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #60758d; }
tr:hover td { background: #fbfcff; }
.address { font-weight: 800; color: var(--navy); }
.sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 800; text-transform: uppercase;
}
.badge.ok { background: var(--greenbg); color: #0d7a4f; }
.badge.ko { background: var(--redbg); color: #b92e3f; }
.badge.warn { background: #fff3e8; color: #c96a17; }

.progress { width: 100px; height: 7px; background: #e6ebf1; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.progress i { display: block; height: 100%; min-width: 3px; background: var(--blue); border-radius: 999px; }

/* Flash */
.flash {
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-size: 13px; font-weight: 700;
}
.flash.success { background: var(--greenbg); color: #0d7a4f; border: 1px solid #b8ead3; }
.flash.error { background: var(--redbg); color: #b92e3f; border: 1px solid #ffd5dc; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; text-align: center; }
.login-card img { max-width: 220px; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 18px; color: var(--navy); font-size: 22px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }

/* Modals */
.modal { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; background: rgba(6,19,38,.45); backdrop-filter: blur(2px); }
.modal.open { display: flex; }
.modal-card { background: var(--card); border-radius: var(--radius); width: min(520px, calc(100% - 24px)); max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(6,19,38,.25); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* Logs */
.logs { background: #0a1520; color: #d5e0eb; padding: 16px; border-radius: 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre; max-height: 70vh; overflow-y: auto; }

/* Pagination */
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 14px; }

/* Footer */
.footer { text-align: center; color: #8a9bb0; font-size: 12px; padding: 24px 0; }

@media (max-width: 960px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .topbar-inner { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; justify-content: center; }
}

@media (max-width: 640px) {
  .summary { grid-template-columns: 1fr; }
  .hero { flex-direction: column; text-align: center; min-height: auto; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
  td { display: flex; justify-content: space-between; align-items: center; border-bottom: 0; padding: 8px 0; }
  td::before { content: attr(data-label); font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 800; }
  .actions { justify-content: flex-end; }
}
