/* Fake RMS — visual mimic of rms.teltonika-networks.com/management/devices */
:root {
  --bg: #f5f7fa;
  --card: #fff;
  --line: #e4e9f0;
  --line2: #eef2f7;
  --ink: #1b2430;
  --ink2: #5b6b7c;
  --ink3: #8a97a8;
  --blue: #1a5cdb;
  --blue-soft: #e8f0fe;
  --green: #10b981;
  --red: #f43f5e;
  --amber: #f59e0b;
  --purple: #7c3aed;
  --rail: 56px;
  --side: 228px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; min-height: 100vh; }

/* Icon rail */
.rail {
  width: var(--rail); flex: 0 0 var(--rail);
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 10px; z-index: 30;
}
.logo { width: 32px; height: 32px; margin-bottom: 20px; color: var(--blue); }
.logo svg { width: 30px; height: 30px; display: block; }
.rail-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; align-items: center; width: 100%; }
.rail a, .rail button.rbtn {
  width: 40px; height: 40px; border: 0; background: transparent; border-radius: 10px;
  color: var(--ink3); display: grid; place-items: center; cursor: pointer; text-decoration: none;
  position: relative;
}
.rail a:hover:not(.disabled), .rail button.rbtn:hover { background: #f3f6fb; color: var(--ink2); }
.rail a.on {
  background: var(--blue-soft); color: var(--blue);
}
.rail a.on::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--blue); border-radius: 0 3px 3px 0;
}
.rail svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.expand {
  width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  color: var(--ink3); cursor: pointer; display: grid; place-items: center;
}
.expand:hover { color: var(--blue); border-color: var(--blue); }
.expand svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* Side panel */
.side {
  width: 0; flex: 0 0 0; overflow: hidden; background: #fff;
  border-right: 0 solid var(--line); transition: width .15s ease, flex-basis .15s ease;
}
.app.open .side { width: var(--side); flex: 0 0 var(--side); border-right-width: 1px; overflow: auto; }
.side-inner { width: var(--side); padding: 14px 10px 28px; }
.side a.side-top { margin-bottom: 4px; font-weight: 600; }
.side .grp { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink3); padding: 12px 10px 4px; }
.side a { display: block; padding: 7px 10px; margin: 1px 0; border-radius: 7px; color: var(--ink2); text-decoration: none; font-size: 13px; }
.side a:hover:not(.disabled) { background: #f5f7fb; }
.side a.on { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.side .note { margin: 16px 10px 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink3); line-height: 1.4; }
.side .note b { color: var(--ink2); }
.side .note code { font-size: 10px; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 54px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 0 18px;
}
.search-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px;
  color: var(--ink3); background: #fafbfc; font-size: 12px;
}
.search-chip kbd {
  font: inherit; font-size: 11px; font-weight: 600; background: #fff;
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--ink2);
}
.ibtn {
  width: 34px; height: 34px; border: 0; background: transparent; border-radius: 8px;
  color: var(--ink3); cursor: pointer; display: grid; place-items: center;
}
.ibtn:hover:not(:disabled):not(.disabled) { background: #f3f6fb; color: var(--ink2); }
.ibtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.user { display: inline-flex; align-items: center; gap: 8px; padding: 3px 6px 3px 3px; border-radius: 999px; cursor: default; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, var(--purple));
  color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center;
}
.uemail { font-size: 12px; color: var(--ink2); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uchev { color: var(--ink3); font-size: 10px; }

.content { padding: 16px 22px 36px; }
.crumb { font-size: 12px; color: var(--ink3); margin: 0 0 2px; }
.crumb b { color: var(--ink2); font-weight: 500; }
.title { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.title h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.help {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line);
  color: var(--ink3); font-size: 11px; font-style: italic; font-weight: 600;
  display: inline-grid; place-items: center; background: #fff; text-decoration: none;
}

/* Cards */
.cards { display: grid; grid-template-columns: 1fr 1.15fr 1.35fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 1050px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; box-shadow: 0 1px 2px rgba(16,24,40,.03);
}
.card-h { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.card-h .ico { color: var(--ink3); display: inline-flex; }
.card-h .ico svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.row:last-child { margin-bottom: 0; }
.lbl { width: 58px; color: var(--ink2); flex: 0 0 58px; }
.cnt { width: 26px; font-weight: 700; text-align: right; flex: 0 0 26px; }
.bar { flex: 1; height: 6px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; }
.bar.red i { background: var(--red); }
.bar.green i { background: var(--green); }
.bar.blue i { background: var(--blue); }
.mlbl { width: auto; flex: 0 0 auto; min-width: 70px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--ink2); }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.btn {
  font: inherit; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover:not(:disabled):not(.disabled) { border-color: #c8d2e0; color: var(--ink); }
.btn.primary {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
.btn.primary:hover:not(:disabled) { background: #1549b5; border-color: #1549b5; color: #fff; }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tsearch {
  flex: 0 1 180px; min-width: 130px; border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 10px; font: inherit; font-size: 12px; background: #fff;
}
.tsearch::placeholder { color: var(--ink3); }
.tsearch:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.view {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 10px; background: #fff; color: var(--ink2); font-size: 12px; font-weight: 600;
}
.view svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.showing { margin-left: auto; font-size: 12px; color: var(--ink3); }
.tright { display: inline-flex; align-items: center; gap: 4px; }
.toggle {
  width: 36px; height: 20px; border-radius: 999px; border: 0; background: var(--blue);
  position: relative; cursor: pointer; padding: 0;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle.off { background: #c5ced9; }
.toggle.off::after { right: auto; left: 2px; }

/* Actions dropdown */
.actions-wrap { position: relative; }
.actions-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40;
  min-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16,24,40,.12); padding: 4px; display: flex; flex-direction: column;
}
.actions-menu[hidden] { display: none; }
.actions-menu button {
  font: inherit; font-size: 12px; text-align: left; padding: 8px 10px; border: 0;
  background: transparent; border-radius: 6px; color: var(--ink); cursor: pointer;
}
.actions-menu button:hover:not(:disabled):not(.disabled) { background: var(--blue-soft); color: var(--blue); }

/* Table */
.wrap {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  overflow: auto; max-height: calc(100vh - 340px); min-height: 260px;
}
table.devs { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12px; }
table.devs thead th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-size: 11px; font-weight: 600;
  color: var(--ink3); padding: 10px 12px; background: #f9fafc; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.devs tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--line2); white-space: nowrap;
  color: var(--ink); vertical-align: middle;
}
table.devs tbody tr:hover td { background: #f7f9fc; }
table.devs tbody tr.hid { display: none; }
.check { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.status { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }
.dot.warn {
  width: 0; height: 0; border-radius: 0; background: transparent; box-shadow: none;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 11px solid var(--amber);
}
.acts { display: inline-flex; gap: 1px; }
.act {
  width: 26px; height: 26px; border: 0; background: transparent; border-radius: 6px;
  color: var(--ink3); cursor: pointer; display: grid; place-items: center;
}
.act:hover:not(.disabled) { background: #eef2f7; color: var(--blue); }
.act svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.name { font-weight: 600; }
.name-edit { margin-left: 3px; border: 0; background: transparent; color: var(--ink3); cursor: pointer; padding: 2px; border-radius: 4px; }
.name-edit:hover { color: var(--blue); background: var(--blue-soft); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--ink2); }
.na { color: var(--ink3); }

.fab {
  position: fixed; right: 18px; bottom: 18px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue); color: #fff; border: 0; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(26,92,219,.35); z-index: 50;
}
.fab.disabled {
  background: #c5ced9; box-shadow: none; opacity: .55;
}

.banner {
  background: #fff8e6; border: 1px solid #f0d78a; color: #6b5410;
  border-radius: 8px; padding: 7px 11px; font-size: 11px; margin-bottom: 12px;
}

/* Disabled / lab-unavailable chrome */
.disabled,
a.disabled,
button.disabled,
button:disabled {
  opacity: .45 !important;
  cursor: not-allowed !important;
  filter: grayscale(.25);
  text-decoration: none !important;
  user-select: none;
}
a.disabled { pointer-events: auto; }
button.disabled:not(:disabled) { pointer-events: auto; }
/* native disabled blocks events; keep visual mute */
button:disabled { pointer-events: none; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1b2430; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 12px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  z-index: 100; max-width: 90vw;
}
.toast[hidden] { display: none; }

/* API status banner */
.api-banner {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.35;
}
.api-banner.ok {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
}
.api-banner.warn {
  background: #fff8e1;
  color: #e65100;
  border: 1px solid #ffe082;
}
