/* FRS Technologies — app styles
   Blue + neutral, quiet, built for scanning lists on a desk or a phone. */

:root {
  /* neutrals */
  --bg:          #f5f6f8;
  --surface:     #ffffff;
  --surface-2:   #f9fafb;
  --border:      #e3e6eb;
  --border-strong:#cfd4dc;
  --text:        #18202b;
  --text-2:      #4a5565;
  --text-3:      #7a8494;

  /* brand blue */
  --blue-900:    #0e1a2b;   /* sidebar */
  --blue-800:    #16263d;
  --blue-700:    #1d3557;
  --blue-600:    #1f5fbf;   /* primary */
  --blue-500:    #2f74d8;
  --blue-100:    #e6effb;
  --blue-50:     #f2f7fd;

  /* status */
  --green:       #1d7a4f;  --green-bg:  #e5f4ec;
  --amber:       #9a5b00;  --amber-bg:  #fdf1dc;
  --red:         #b4332a;  --red-bg:    #fbe8e6;
  --gray-bg:     #eef0f3;

  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg:   0 12px 32px rgba(16, 24, 40, .16);

  --sidebar-w:   248px;
  --topbar-h:    60px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none;
        stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Shell ─────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-900);
  color: #c9d3e1;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0;
  z-index: 40;
}
.wordmark {
  display: block;
  padding: 22px 22px 20px;
  color: #fff;
  text-decoration: none !important;
  line-height: 1.05;
}
.wordmark { font-size: 23px; font-weight: 700; letter-spacing: -0.025em; white-space: nowrap; }
.wordmark .w2 { font-weight: 500; color: #9db4d3; }

.nav { padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
             color: #6d7f98; padding: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: #c9d3e1; font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--blue-800); color: #fff; }
.nav a.active { background: var(--blue-700); color: #fff; box-shadow: inset 3px 0 0 var(--blue-500); }
.nav a .icon { opacity: .85; }
.nav .soon { margin-left: auto; font-size: 10.5px; font-weight: 600; color: #6d7f98;
             border: 1px solid #2a3b55; border-radius: 99px; padding: 1px 7px; }

.sidebar-foot { padding: 14px 16px; border-top: 1px solid #1c2c44; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue-700); color: #fff;
          display: grid; place-items: center; font-weight: 600; font-size: 13px; text-transform: uppercase; flex: none; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { display: block; font-size: 12px; color: #8193ab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot a.logout { color: #8193ab; padding: 6px; border-radius: 6px; display: grid; }
.sidebar-foot a.logout:hover { color: #fff; background: var(--blue-800); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; min-width: 0; }
.crumbs a { color: var(--text-2); }
.crumbs .sep { color: var(--border-strong); }
.crumbs .here { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar-mark { display: none; }

.content { padding: 28px; max-width: 1320px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: 500 14px/1 var(--font);
  cursor: pointer; white-space: nowrap;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: #b9c0cb; }
.btn:focus-visible, .nav a:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue-500); outline-offset: 2px;
}
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: #1a52a6; border-color: #1a52a6; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: #e9b4ae; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { width: 36px; padding: 0; }

/* ── Cards & stats ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
             padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; }
.card-head a { font-size: 13px; font-weight: 500; }
.card-body { padding: 18px; }

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 16px 18px; }
.stat .label { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.stat .label .icon { width: 16px; height: 16px; color: var(--text-3); }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.1; }
.stat .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.stat.warn .value { color: var(--amber); }
.stat.bad .value { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; }

/* building cards */
.bcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.bcard { display: block; padding: 16px 18px; color: inherit; text-decoration: none !important; transition: border-color .15s, box-shadow .15s; }
.bcard:hover { border-color: #b8c7dc; box-shadow: 0 4px 14px rgba(16, 24, 40, .07); }
.bcard .top { display: flex; gap: 12px; align-items: flex-start; }
.bcard .bicon { width: 38px; height: 38px; border-radius: 8px; background: var(--blue-50); color: var(--blue-600);
                display: grid; place-items: center; flex: none; }
.bcard h3 { font-size: 15px; }
.bcard .addr { color: var(--text-3); font-size: 12.5px; margin-top: 1px; }
.bcard .counts { display: flex; gap: 18px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.bcard .counts div { font-size: 12.5px; color: var(--text-2); }
.bcard .counts b { font-size: 16px; color: var(--text); display: block; font-weight: 600; }

/* lists (needs attention, customers) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; }
.list .meta { color: var(--text-3); font-size: 12.5px; }
.empty { padding: 28px 18px; text-align: center; color: var(--text-3); }
.empty .icon { width: 28px; height: 28px; color: var(--border-strong); display: block; margin: 0 auto 8px; }

/* ── Badges ────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px;
         font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--gray-bg); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.online  { background: var(--green-bg); color: var(--green); }
.badge.offline { background: var(--red-bg);   color: var(--red); }
.badge.active  { background: var(--blue-100); color: var(--blue-600); }
.badge.warn    { background: var(--amber-bg); color: var(--amber); }
.badge.plain::before { display: none; }

.battery { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.battery .bar { width: 34px; height: 8px; border-radius: 3px; background: var(--gray-bg); overflow: hidden; }
.battery .bar i { display: block; height: 100%; background: var(--green); }
.battery.low .bar i { background: var(--red); }
.battery.mid .bar i { background: #d59a20; }

/* ── Tables ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase;
            letter-spacing: .05em; padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--blue-50); }
.table tr.clickable { cursor: pointer; }
.table .strong { font-weight: 500; color: var(--text); }
.table .right { text-align: right; }
.table .sub { color: var(--text-3); font-size: 12.5px; }

/* ── Tabs ──────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 12px 10px;
               font: 500 14px var(--font); color: var(--text-2); cursor: pointer; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--blue-600); box-shadow: inset 0 -2px 0 var(--blue-600); }
.tabs .count { font-size: 12px; background: var(--gray-bg); color: var(--text-2); border-radius: 99px; padding: 0 7px; }
.tabpanel[hidden] { display: none; }

/* ── Detail header ─────────────────────────────────────────────────── */
.detail-head { display: flex; gap: 16px; align-items: flex-start; }
.detail-head .bicon { width: 52px; height: 52px; border-radius: 12px; background: var(--blue-100); color: var(--blue-600);
                      display: grid; place-items: center; flex: none; }
.detail-head .bicon .icon { width: 26px; height: 26px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 6px; color: var(--text-2); font-size: 13px; }
.facts span { display: inline-flex; align-items: center; gap: 6px; }
.facts .icon { width: 15px; height: 15px; color: var(--text-3); }

/* ── Forms & modal ─────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field input, .field select, .field textarea {
  height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: 400 14px var(--font); color: var(--text); background: #fff; width: 100%;
}
.field textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--text-3); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin: -4px 0 8px; }

dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--text); }
dialog.modal { max-height: calc(100vh - 32px); overflow: auto; }
dialog.modal.wide { width: min(680px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(14, 26, 43, .45); }
.modal-head { padding: 18px 20px 6px; display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 10px 20px 4px; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

.alert-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 18px;
             background: var(--amber-bg); border: 1px solid #f3dcae; border-radius: var(--radius); color: #6b4300; flex-wrap: wrap; }
.alert-bar span { flex: 1; min-width: 200px; }
.alert-bar > .icon { color: var(--amber); }

/* find-me dialog */
.findme .fm-label { margin: -4px 0 12px; }
.fm-state { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: 10px;
            background: var(--blue-50); border: 1px solid var(--blue-100); margin-bottom: 14px; }
.fm-state p { margin: 2px 0 0; font-size: 13px; }
.fm-state > .icon { width: 24px; height: 24px; margin-top: 1px; }
.fm-state.ok   { background: var(--green-bg); border-color: #c6e6d4; } .fm-state.ok > .icon { color: var(--green); }
.fm-state.warn { background: var(--amber-bg); border-color: #f3dcae; } .fm-state.warn > .icon { color: var(--amber); }
.fm-state.bad  { background: var(--red-bg);   border-color: #f1c6c1; } .fm-state.bad > .icon { color: var(--red); }
.fm-count { margin-left: auto; font-size: 22px; font-weight: 600; color: var(--blue-600); }
.findme .modal-foot { padding: 4px 0 2px; }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--blue-500); flex: none; margin-top: 3px;
         box-shadow: 0 0 0 0 rgba(47, 116, 216, .55); animation: pulse 1s infinite; }
.pulse.slow { animation-duration: 1.8s; background: var(--text-3); box-shadow: 0 0 0 0 rgba(122, 132, 148, .5); }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(47, 116, 216, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 116, 216, 0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* key/value details */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; }
.kv dt { color: var(--text-3); font-size: 13px; }
.kv dd { margin: 0; }

/* filters */
.filters { display: flex; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filters input, .filters select { height: 36px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
                                   padding: 0 10px; font: 400 14px var(--font); background: #fff; color: var(--text); }
.filters input[type=search] { flex: 1; min-width: 180px; }
@media (max-width: 640px) { .filters select { flex: 1; } .filters input, .filters select { height: 42px; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
         background: var(--blue-900); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg);
         font-weight: 500; transition: all .2s; z-index: 100; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

.scrim { display: none; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(14, 26, 43, .45); z-index: 30; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; margin-left: -8px; }
  .topbar { padding: 0 16px; }
  .topbar-mark { display: block; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; }
  .topbar .crumbs { display: none; }
  .content { padding: 20px 16px 32px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .stats, .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat .value { font-size: 24px; }
  .page-head h1 { font-size: 21px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; height: 42px; }
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }

  /* tables become stacked cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--text-3); font-size: 13px; text-align: left; }
  .table td.primary { display: block; text-align: left; padding-bottom: 6px; }
  .table td.primary::before { display: none; }
  .table td.actions { justify-content: flex-end; padding-top: 8px; }
  .table td.actions::before { display: none; }
  .table td.actions .btn { flex: 1; }
  .table tbody tr:hover td { background: none; }
  .detail-head .bicon { width: 44px; height: 44px; }
}
