/* ============================================================
   Rindy dealer cabinet — styles
   Plain CSS, no framework, no external fonts (CDN blocked in RU).
   Palette matches the rindy.ru landing: mint-light base,
   dark-green "islands" (topbar/login), accent #0fa06f / #2fe3a6.
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* light base (landing) */
  --bg:        #eef3ef;
  --card:      #ffffff;
  --card-2:    #f4f8f5;
  --ink:       #0f1a15;
  --ink-2:     #46554d;
  --muted:     #7a887f;
  --border:    #e0e7e2;
  /* dark islands (topbar / login) */
  --dark:      #0c110f;
  --dark-2:    #141b18;
  --d-ink:     #f1f5f2;
  --d-ink-2:   #aeb9b2;
  --d-muted:   #6c7a72;
  --d-border:  rgba(255,255,255,.09);
  --d-border-2:rgba(255,255,255,.16);
  /* accents: sat for light bg, bright for dark bg */
  --accent:      #0fa06f;
  --accent-d:    #0c855c;
  --accent-soft: rgba(15,160,111,.1);
  --accent-line: rgba(15,160,111,.28);
  --accent-br:   #2fe3a6;
  --accent-ink:  #04180f;
  --ok:        #0fa06f;
  --bad:       #dc2626;
  --mono:      ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --shadow:    0 1px 3px rgba(15,40,28,.06), 0 1px 2px rgba(15,40,28,.04);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- Login (dark island, like the landing hero) ---- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--dark);
  position: relative;
  overflow: hidden;
}
.login-body::before {
  content: "";
  position: fixed;
  right: -10%;
  top: -25%;
  width: 65%;
  height: 130%;
  background: radial-gradient(closest-side, rgba(47,227,166,.16), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}
.login-card {
  background: var(--card);
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 30px 60px -24px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 2;
}
.brand-big {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .2em;
  text-align: center;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.brand-big .mark,
.brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-br);
  display: inline-grid;
  place-items: center;
  color: var(--accent-ink);
  flex-shrink: 0;
}
.brand-big .mark svg, .brand .mark svg { width: 17px; height: 17px; }
.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.login-foot {
  text-align: center;
  font-size: 13px;
  margin-top: 2px;
}
.login-foot a { color: var(--muted); text-decoration: none; transition: color .15s; }
.login-foot a:hover { color: var(--accent-d); }

/* ---- Form fields ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
input, select, textarea {
  font-size: 15px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fbfdfc;
  color: var(--ink);
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #fff;
}
input::placeholder { color: #9aa8a0; }
input[readonly] { background: var(--card-2); color: var(--ink-2); }

button {
  font-size: 15px;
  font-weight: 700;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, transform .12s, box-shadow .2s;
  box-shadow: 0 8px 24px -12px rgba(15,160,111,.55);
}
button:hover { background: var(--accent-d); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .6; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
}
.btn-ghost:hover { background: var(--card-2); color: var(--ink); border-color: var(--accent-line); }

.error {
  color: var(--bad);
  font-size: 14px;
  min-height: 18px;
  text-align: center;
}

/* ---- Topbar (dark island, like the landing header) ---- */
.topbar {
  background: var(--dark);
  border-bottom: 1px solid var(--d-border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .2em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .mark { width: 26px; height: 26px; border-radius: 7px; }
.brand .mark svg { width: 15px; height: 15px; }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 600; font-size: 14px; color: var(--d-ink); }
.role-badge {
  font-size: 11.5px;
  font-family: var(--mono);
  letter-spacing: .06em;
  background: rgba(47,227,166,.12);
  color: var(--accent-br);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(47,227,166,.25);
}
.topbar .btn-ghost {
  color: #d4dae2;
  border-color: var(--d-border-2);
}
.topbar .btn-ghost:hover { background: rgba(255,255,255,.06); color: #fff; border-color: rgba(255,255,255,.3); }

/* ---- Topbar navigation ---- */
.topbar-left { display: flex; align-items: center; gap: 28px; }
.nav { display: flex; gap: 4px; }
.nav-link {
  text-decoration: none;
  color: var(--d-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-link.active { color: var(--accent-br); background: rgba(47,227,166,.1); }

/* ---- Content ---- */
.content { max-width: 980px; margin: 0 auto; padding: 28px 24px; }
.content h2 { font-size: 20px; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 14px; }

/* ---- Device cards ---- */
.devices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.device-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.device-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
  box-shadow: 0 16px 34px -22px rgba(15,90,60,.35);
}
.device-card:active { transform: translateY(0); }

/* ---- Device page ---- */
.back-link {
  color: var(--accent-d);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 14px;
}
.back-link:hover { text-decoration: underline; }
.device-page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.device-page-head h2 { margin: 0; }
.device-sub { color: var(--muted); font-size: 13px; font-family: var(--mono); margin-top: 3px; }
.device-page-actions { margin-top: 14px; }
.section-title { font-size: 16px; margin: 26px 0 12px; }
.device-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.device-name { font-weight: 700; font-size: 15px; color: var(--ink); }
.device-meta { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.status-dot.offline { background: #c3ccc6; }

/* ---- Login: forms & steps ---- */
.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hidden { display: none !important; }
.hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 2px;
}
.hint b { color: var(--ink); }

/* ---- Page head ---- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head h2 { margin: 0; }
.page-head-actions { display: flex; gap: 10px; align-items: center; }
.search-input { width: 240px; padding: 8px 12px; font-size: 14px; }

/* ---- Device card actions ---- */
.device-actions { margin-top: 10px; }

/* ---- Data table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 11px 14px;
  background: var(--card-2);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--accent-soft); }
/* Ячейка действий — ОБЫЧНАЯ ячейка таблицы (не flex!), чтобы разделители строк шли ровно под кнопками.
   Кнопки раскладываем инлайн, в один ряд, без переноса. */
.row-actions { white-space: nowrap; vertical-align: middle; text-align: right; }
.row-actions button { display: inline-block; vertical-align: middle; }
.row-actions button + button { margin-left: 5px; }
.data-table td { vertical-align: middle; }
/* «Идентификатор» (3-я колонка таблицы абонентов) забирает всю лишнюю ширину, чтобы кнопки не наезжали. */
#subscribers .data-table td:nth-child(3), #subscribers .data-table th:nth-child(3) { width: 99%; }

/* ---- Badges ---- */
.badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
}
.badge-ok  { background: var(--accent-soft); color: var(--accent-d); }
.badge-bad { background: #fee2e2; color: #b91c1c; }
.badge-gsm { background: #dbeafe; color: #1d4ed8; }
.badge-ble { background: #e0e7ff; color: #4338ca; }
.badge-rf  { background: #fef3c7; color: #b45309; }
.badge-app  { background: #ccfbf1; color: #0f766e; }
.badge-wifi { background: #fce7f3; color: #be185d; }
.badge-lora { background: #dcfce7; color: #047857; }

/* "Open device" primary button on the device page */
.btn-mini.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 700;
}
.btn-mini.btn-primary:hover { background: var(--accent-d); }

/* ---- Device capabilities row in header ---- */
.device-caps {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.caps-label { font-size: 13px; color: var(--muted); }

/* ---- Capabilities (fieldset of channel checkboxes) ---- */
.caps-set {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px 10px;
  margin: 0;
  background: #fbfdfc;
}
.caps-set legend {
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 6px;
}
.cap-check {
  display: block;
  padding: 5px 0;
  font-size: 14px;
  cursor: pointer;
}
.cap-check input {
  margin-right: 8px;
  vertical-align: middle;
  width: auto;
  accent-color: var(--accent);
}
.caps-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ---- Mini buttons ---- */
.btn-mini {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  background: var(--card-2);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: none;
  white-space: nowrap;   /* не переносить текст внутри кнопки */
}
.btn-mini:hover { background: #e7efe9; }
.btn-danger { color: var(--bad); border-color: #f3c6c6; }
.btn-danger:hover { background: #fee2e2; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,16,13,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card {
  background: var(--card);
  width: 100%;
  max-width: 400px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 24px;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 30px 60px -24px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card h3 { font-size: 17px; letter-spacing: -.01em; margin-bottom: 4px; }
.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.modal-actions button { width: auto; }

/* ---- Tabs (dashboard: 'В работе' / 'Склад') ---- */
.tabs {
  display: flex;
  gap: 0;
  margin: 4px 0 16px 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: 0;
  width: auto;
  box-shadow: none;
}
.tab:hover { color: var(--ink); background: transparent; }
.tab.active {
  color: var(--accent-d);
  border-bottom-color: var(--accent);
}

/* ---- Sub-tabs (in device page Abonenty) ---- */
.tabs-sub {
  margin: 0 0 14px 0;
  border-bottom: 1px solid #e8eee9;
}
.tabs-sub .tab {
  font-size: 13px;
  padding: 8px 14px;
}
.tab-pane { margin-top: 16px; }

/* ---- Sub-toolbar (search + action button) ---- */
.sub-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 6px 0 10px 0;
}
.sub-toolbar .search-input { flex: 1; }
.sub-toolbar button { width: auto; flex-shrink: 0; }

/* ---- Section title alongside ---- */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0 10px 0;
}
.section-head .section-title { margin: 0; }

/* ---- Frozen subscriber row ---- */
.row-frozen td { opacity: 0.55; }
.badge-frozen {
  background: #e2ebe5;
  color: #4c6255;
  border: 1px solid #cfdcd3;
  font-weight: 500;
}

/* ---- App-юзер: кликабельная строка, сворачивание/разворачивание ---- */
.app-row { cursor: pointer; }
.app-row:hover td { background: var(--accent-soft); }
.app-row .row-actions { cursor: default; }   /* кнопки не должны выглядеть кликабельными «строкой» */
.app-meta { color: var(--muted); font-size: 12px; margin-left: 6px; white-space: nowrap; }
.app-chev { display: inline-block; width: 0.9em; color: var(--muted); }
.app-count { color: var(--muted); }

/* ---- Под app-юзером: список зарегистрированных телефонов ---- */
.row-detail td {
  background: var(--card-2);
  padding: 10px 14px 14px 14px;
  border-bottom: 1px solid var(--border);
}
.phones-list { display: flex; flex-direction: column; gap: 6px; }
.phone-chip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.phone-chip-frozen { opacity: 0.65; background: var(--card-2); }
.phone-actions { margin-left: auto; display: flex; gap: 6px; }
.phones-hint {
  margin-top: 6px; padding: 8px 10px;
  background: #fff8e1; border: 1px solid #f5e3a8; border-radius: 8px;
  color: #5a4a10; font-size: 12px;
}

/* ---- Inline pencil-rename next to device title ---- */
#renameBtnInline {
  font-size: 14px;
  padding: 2px 8px;
  line-height: 1.2;
  width: auto;
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .topbar-left { gap: 14px; }
  .user-name { display: none; }
  .content { padding: 20px 14px; }
  .search-input { width: 100%; }
  .page-head-actions { flex-wrap: wrap; }
}

/* Перетаскивание карточек приборов (dashboard) */
.device-card { cursor: grab; }
.device-card.dragging { opacity: .45; cursor: grabbing; }

/* Папки дилеров (dashboard, фаундер) */
.folder-back { display:block; grid-column:1 / -1; cursor:pointer; color:var(--accent); font-weight:600; margin:0 0 4px; }
.folder-back:hover { text-decoration:underline; }
.dealer-folder .device-name { font-weight:700; }

/* Строка гео-открытия + тумблер (device.html) */
.geo-row { display:flex; align-items:center; gap:14px; padding:14px 16px; background:var(--card); border:1px solid var(--border); border-radius:14px; margin:12px 0 4px; box-shadow:var(--shadow); }
.geo-ico { font-size:22px; line-height:1; }
.geo-body { flex:1 1 auto; min-width:0; }
.geo-title { font-weight:600; color:var(--ink); display:flex; align-items:center; gap:8px; }
.geo-state { font-size:12px; font-weight:600; padding:2px 9px; border-radius:999px; }
.geo-state.on  { color:var(--accent); background:var(--accent-soft); }
.geo-state.off { color:var(--muted);  background:var(--card-2); }
.geo-sub { font-size:12px; color:var(--muted); margin-top:3px; }
.rindy-switch { position:relative; display:inline-block; width:46px; height:26px; flex:0 0 auto; }
.rindy-switch input { opacity:0; width:0; height:0; }
.rindy-switch-slider { position:absolute; inset:0; background:#cdd6d0; border-radius:999px; transition:.2s; cursor:pointer; }
.rindy-switch-slider::before { content:''; position:absolute; width:20px; height:20px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; box-shadow:0 1px 3px rgba(0,0,0,.25); }
.rindy-switch input:checked + .rindy-switch-slider { background:var(--accent); }
.rindy-switch input:checked + .rindy-switch-slider::before { transform:translateX(20px); }
