/* =============================================================
   Rodnet Staff Portal — portal.css
   ============================================================= */

:root {
  --bg:       #07101E;
  --bg-card:  #0D1929;
  --bg-up:    #112240;
  --border:   rgba(255,255,255,.07);
  --blue:     #0284C7;
  --blue-lt:  #38BDF8;
  --orange:   #F97316;
  --teal:     #0D9488;
  --amber:    #F59E0B;
  --red:      #EF4444;
  --green:    #10B981;
  --purple:   #7C3AED;
  --text-1:   #F0F6FF;
  --text-2:   #7A9BBE;
  --r:        10px;
  --r-sm:     7px;
  --t:        .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
html { scroll-behavior: smooth }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none }
ul { list-style: none }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit }
input, select, textarea { font-family: inherit }

/* ── Layout shell ── */
.app-shell { display: flex; min-height: 100vh; overflow-x: hidden }
.main-wrap  { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: hidden }
.page-content { flex: 1; padding: 24px 28px; overflow-y: auto }
body.no-pad .page-content { padding: 0; overflow: hidden }

/* ── Sidebar ── */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  transition: transform var(--t);
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; border-bottom: 1px solid var(--border);
}
.sb-logo-box {
  width: 32px; height: 32px; border-radius: 7px;
  background: var(--orange); display: grid; place-items: center;
  font-size: .85rem; font-weight: 900; color: #fff; flex-shrink: 0;
}
.sb-brand-text { font-size: .9rem; font-weight: 700; line-height: 1.2 }
.sb-brand-text span { display: block; color: var(--text-2); font-size: .72rem; font-weight: 400 }
.sb-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px }
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: .85rem; font-weight: 500;
  transition: color var(--t), background var(--t);
  position: relative;
}
.sb-link i  { width: 16px; text-align: center; flex-shrink: 0 }
.sb-link:hover, .sb-link.active { color: var(--text-1); background: rgba(255,255,255,.05) }
.sb-link.active { color: var(--orange) }
.sb-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: .65rem; font-weight: 700; padding: 2px 6px;
  border-radius: 99px; min-width: 18px; text-align: center;
}
.sb-footer {
  padding: 14px 10px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.sb-user { display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden }
.sb-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--orange); display: grid; place-items: center;
  font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sb-user-info { overflow: hidden }
.sb-user-info strong { display: block; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.sb-user-info span   { font-size: .7rem; color: var(--text-2); text-transform: capitalize }
.sb-logout { color: var(--text-2); padding: 6px; border-radius: 6px; transition: color var(--t), background var(--t) }
.sb-logout:hover { color: var(--red); background: rgba(239,68,68,.08) }

/* ── Topnav ── */
.topnav {
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ham-btn { display: none; color: var(--text-2); padding: 6px; border-radius: 6px; transition: color var(--t) }
.ham-btn:hover { color: var(--text-1) }
.topnav-title { font-weight: 700; font-size: .95rem }
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 8px }
.notif-btn {
  position: relative; color: var(--text-2); padding: 6px; border-radius: 6px; transition: color var(--t);
}
.notif-btn:hover { color: var(--text-1) }
.notif-dot {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange); border: 2px solid var(--bg-card);
}
.topnav-logout { color: var(--text-2); padding: 6px; border-radius: 6px; transition: color var(--t) }
.topnav-logout:hover { color: var(--red) }

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 24px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h3 { font-size: .95rem; font-weight: 700 }
.card-link     { font-size: .8rem; color: var(--blue-lt) }

/* ── Stats row ── */
.stats-row {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px;
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(2,132,199,.12);  color: var(--blue-lt) }
.stat-icon.orange { background: rgba(249,115,22,.12); color: var(--orange) }
.stat-icon.teal   { background: rgba(13,148,136,.12); color: #2DD4BF }
.stat-icon.green  { background: rgba(16,185,129,.12); color: var(--green) }
.stat-body strong { display: block; font-size: 1.6rem; font-weight: 900; line-height: 1.1 }
.stat-body span   { font-size: .78rem; color: var(--text-2) }

/* ── Dashboard grid ── */
.dash-grid {
  display: grid; grid-template-columns: 1fr 320px;
  gap: 20px;
}
.dash-side { display: flex; flex-direction: column; gap: 20px }

/* Online staff */
.online-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 }
.online-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
}
.online-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--orange); display: grid; place-items: center;
  font-size: .75rem; font-weight: 700; color: #fff;
}
.online-item > div strong { display: block; font-size: .85rem }
.online-item > div span   { font-size: .75rem; color: var(--text-2) }
.online-dot {
  margin-left: auto; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
}

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.qa-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px;
  font-size: .82rem; font-weight: 600;
  transition: border-color var(--t), background var(--t);
}
.qa-btn:hover { border-color: var(--orange); color: var(--orange) }
.qa-btn i { font-size: .85rem }

/* ── Tables ── */
.table-wrap { overflow-x: auto }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem }
.data-table th {
  padding: 9px 12px; text-align: left;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 11px 12px; border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
.data-table tr:last-child td { border: none }
.data-table tr:hover td { background: rgba(255,255,255,.02) }
.row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap }

/* ── Badges ── */
.badge {
  display: inline-block; font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px;
}
.p-normal  { background: rgba(100,116,139,.15); color: #94A3B8 }
.p-high    { background: rgba(245,158,11,.12);  color: var(--amber) }
.p-urgent  { background: rgba(239,68,68,.12);   color: var(--red) }
.s-available   { background: rgba(56,189,248,.1);  color: var(--blue-lt) }
.s-assigned    { background: rgba(245,158,11,.1);  color: var(--amber) }
.s-inprogress  { background: rgba(13,148,136,.1);  color: #2DD4BF }
.s-completed   { background: rgba(16,185,129,.1);  color: var(--green) }
.s-incomplete  { background: rgba(239,68,68,.1);   color: var(--red) }
.role-admin     { background: rgba(124,58,237,.12); color: #A78BFA }
.role-staff     { background: rgba(255,255,255,.06); color: var(--text-2) }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .875rem; font-weight: 600; padding: 9px 18px;
  border-radius: var(--r-sm); transition: all var(--t); cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--orange); color: #fff }
.btn-primary:hover { background: #FB923C }
.btn-teal    { background: var(--teal); color: #fff }
.btn-teal:hover { background: #0F766E }
.btn-ghost   { border: 1px solid var(--border); color: var(--text-2) }
.btn-ghost:hover { border-color: rgba(255,255,255,.15); color: var(--text-1) }
.btn-danger  { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.2) }
.btn-danger:hover { background: var(--red); color: #fff }
.btn-sm      { padding: 6px 12px; font-size: .8rem }
.btn-full    { width: 100%; justify-content: center }

.btn-icon {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 6px; font-size: .8rem; color: var(--text-2);
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  transition: all var(--t);
}
.btn-icon:hover         { color: var(--text-1); border-color: rgba(255,255,255,.15) }
.btn-icon.danger:hover  { color: var(--red); border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.08) }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: min(560px, calc(100% - 40px));
  max-height: 90vh; overflow-y: auto;
}
.modal.modal-sm { max-width: min(380px, calc(100% - 40px)) }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h3    { font-size: 1rem; font-weight: 700 }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center; font-size: .85rem;
  color: var(--text-2); transition: all var(--t);
}
.modal-close:hover { background: rgba(255,255,255,.06); color: var(--text-1) }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px }
.modal-foot .btn { min-width: 110px }
.modal .form-group { min-width: 0; width: 100% }
.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea { width: 100%; box-sizing: border-box }
.modal .form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-width: 0 }
.modal .form-row-2 > * { min-width: 0 }
.modal .checkbox-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--text-2); font-size: .9rem }
.modal .checkbox-row input { margin: 0; width: auto }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px }
.form-group label { font-size: .78rem; font-weight: 600; color: var(--text-2) }
.form-group input,
.form-group select,
.form-group textarea {
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-1);
  font-size: .88rem; padding: 9px 12px; outline: none;
  transition: border-color var(--t);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue-lt) }
.form-group select option   { background: #0D1929 }
.form-group textarea        { resize: vertical }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-2) }
.form-group textarea        { resize: vertical }
.checkbox-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--text-2); font-size: .9rem }
.checkbox-row input { margin: 0; width: auto }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px }

/* ── Toolbar / filters ── */
.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap }
.ftab {
  padding: 6px 14px; border-radius: 6px; font-size: .82rem; font-weight: 500;
  color: var(--text-2); background: rgba(255,255,255,.03); border: 1px solid var(--border);
  transition: all var(--t);
}
.ftab:hover, .ftab.active { color: var(--text-1); background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12) }
.ftab.active { color: var(--orange); border-color: rgba(249,115,22,.3) }

/* ── Tab bar ── */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tab {
  padding: 9px 18px; font-size: .875rem; font-weight: 600;
  color: var(--text-2); border-bottom: 2px solid transparent;
  transition: color var(--t), border-color var(--t);
}
.tab:hover { color: var(--text-1) }
.tab.active { color: var(--orange); border-bottom-color: var(--orange) }

/* ── Alerts ── */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-sm);
  font-size: .875rem; margin-bottom: 16px;
}
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.2); color: var(--green) }
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.2);  color: var(--red) }

/* ── Toast ── */
#toastContainer {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 18px;
  font-size: .875rem; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slideIn .2s ease; min-width: 250px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue-lt); }
@keyframes slideIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }

/* ── Utilities ── */
.text-muted  { color: var(--text-2) }
.text-center { text-align: center }
.text-sm     { font-size: .8rem }
.mt-4        { margin-top: 20px }
.p-3         { padding: 12px }
.p-4         { padding: 16px }

/* ── Login page ── */
body.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-wrap { width: 100%; max-width: 400px; padding: 24px }
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px;
}
.login-brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 28px;
}
.login-title { font-size: 1.1rem; font-weight: 800 }
.login-title span { display: block; color: var(--text-2); font-weight: 400; font-size: .85rem }
.login-form  { display: flex; flex-direction: column; gap: 16px }
.login-back  { text-align: center; margin-top: 18px }
.login-back a { color: var(--text-2); font-size: .85rem }
.login-back a:hover { color: var(--text-1) }

/* ── Settings ── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start }
.settings-form { display: flex; flex-direction: column; gap: 16px }

/* ── Network ── */
.network-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px }
.network-header h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 4px }
.node-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
/* Router table — mobile only */
.router-table-wrap { display: none }
.node-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.node-card.status-warning { border-color: rgba(245,158,11,.25) }
.node-card.status-offline  { border-color: rgba(239,68,68,.25) }
.node-top { display: flex; align-items: center; justify-content: space-between }
.node-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(2,132,199,.1); display: grid; place-items: center;
  font-size: 1rem; color: var(--blue-lt);
}
.node-card.status-warning .node-icon { background: rgba(245,158,11,.1); color: var(--amber) }
.node-card.status-offline  .node-icon { background: rgba(239,68,68,.1);  color: var(--red) }
.node-status-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.node-card.status-warning .node-status-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber) }
.node-card.status-offline  .node-status-dot { background: var(--red);   box-shadow: none }
.node-name { font-weight: 700; font-size: .95rem }
.node-location { font-size: .78rem }
.node-bar {
  height: 5px; background: rgba(255,255,255,.06); border-radius: 99px; overflow: hidden;
}
.node-fill { height: 100%; background: var(--green); border-radius: 99px }
.node-card.status-warning .node-fill { background: var(--amber) }
.node-card.status-offline  .node-fill { background: var(--red) }
.node-meta { display: flex; align-items: center; justify-content: space-between; font-size: .78rem }
.node-pct  { color: var(--text-2) }
.node-status-label { font-weight: 700; color: var(--green) }
.node-card.status-warning .node-status-label { color: var(--amber) }
.node-card.status-offline  .node-status-label { color: var(--red) }
.node-notes { font-size: .78rem; color: var(--text-2) }
.node-btn   { margin-top: auto }
.legend-row {
  display: flex; gap: 32px; flex-wrap: wrap; font-size: .85rem;
  color: var(--text-2);
}
.dot-online  { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green);  margin-right: 5px }
.dot-warning { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--amber);  margin-right: 5px }
.dot-offline { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--red);    margin-right: 5px }

/* ── Clients page ── */
.page-intro { margin-bottom: 28px }
.page-intro h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 6px }
.client-portal-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.cp-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 22px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color var(--t), transform var(--t);
}
.cp-card:hover { border-color: rgba(56,189,248,.25); transform: translateY(-2px) }
.cp-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: rgba(2,132,199,.1); display: grid; place-items: center;
  font-size: 1.1rem; color: var(--blue-lt);
}
.cp-icon.orange { background: rgba(249,115,22,.1); color: var(--orange) }
.cp-body h3  { font-size: .9rem; font-weight: 700; margin-bottom: 4px }
.cp-body p   { font-size: .82rem; color: var(--text-2); line-height: 1.6 }
.cp-ext { margin-left: auto; font-size: .75rem; color: var(--text-2); flex-shrink: 0 }
.billnasi-note {
  display: flex; align-items: flex-start; gap: 14px;
}
.billnasi-note > i { color: var(--blue-lt); font-size: 1.1rem; margin-top: 2px; flex-shrink: 0 }
.billnasi-note strong { display: block; margin-bottom: 4px }
.billnasi-note p { font-size: .85rem; color: var(--text-2) }

/* ── Messages ── */
body.fill-layout .main-wrap { height: 100vh; overflow: hidden }
body.fill-layout .page-content { height: calc(100vh - 56px); display: flex; flex-direction: column }
.msg-shell {
  display: flex; flex: 1; overflow: hidden;
  border-radius: var(--r); border: 1px solid var(--border);
  background: var(--bg-card); height: 100%;
}
.msg-contacts {
  width: 280px; flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.msg-contacts-head {
  padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.msg-contacts-head h3 { font-size: .95rem; font-weight: 700 }
.msg-contacts-list { flex: 1; overflow-y: auto }
.msg-loading { padding: 24px; text-align: center; color: var(--text-2) }
.contact-item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.03);
  transition: background var(--t);
}
.contact-item-row:hover, .contact-item-row.active { background: rgba(255,255,255,.04) }
.contact-item-row.active { border-left: 2px solid var(--orange) }
.ci-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue); display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; color: #fff;
}
.ci-avatar.grp { background: var(--teal); border-radius: 8px }
.ci-info { flex: 1; min-width: 0 }
.ci-info strong { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ci-info span   { font-size: .75rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block }
.ci-badge {
  background: var(--orange); color: #fff;
  font-size: .62rem; font-weight: 700; padding: 2px 6px;
  border-radius: 99px; flex-shrink: 0;
}
.contact-section-label {
  padding: 8px 16px 4px; font-size: .68rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-2);
}

/* Chat area */
.msg-chat { flex: 1; display: flex; flex-direction: column; overflow: hidden }
.msg-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-2); gap: 12px }
.msg-empty i { font-size: 2.5rem; opacity: .3 }
.msg-empty p  { font-size: .9rem }
.msg-chat-inner { flex: 1; display: flex; flex-direction: column; overflow: hidden }
.msg-chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.msg-back { display: none; color: var(--text-2); padding: 4px 8px; border-radius: 6px }
.chat-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: #fff;
  background: var(--blue);
}
.chat-head-info strong { display: block; font-size: .9rem; font-weight: 700 }
.chat-head-info span   { font-size: .75rem; color: var(--text-2) }
.msg-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px }
.msg-bubble-wrap { display: flex; gap: 8px; max-width: 70% }
.msg-bubble-wrap.own { margin-left: auto; flex-direction: row-reverse }
.bubble-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: .65rem; font-weight: 700;
  background: var(--blue); color: #fff; align-self: flex-end;
}
.msg-bubble-wrap.own .bubble-avatar { background: var(--orange) }
.bubble-inner { display: flex; flex-direction: column; gap: 3px }
.bubble-name  { font-size: .68rem; color: var(--text-2) }
.bubble {
  background: rgba(255,255,255,.07); border-radius: 12px 12px 12px 0;
  padding: 9px 13px; font-size: .875rem; line-height: 1.5; word-break: break-word;
}
.msg-bubble-wrap.own .bubble { background: rgba(249,115,22,.15); border-radius: 12px 12px 0 12px }
.bubble-time { font-size: .65rem; color: var(--text-2) }
.msg-composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.msg-composer textarea {
  flex: 1; background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-1); font-size: .9rem;
  padding: 9px 14px; resize: none; outline: none; max-height: 120px;
  transition: border-color var(--t);
}
.msg-composer textarea:focus { border-color: var(--blue-lt) }
.msg-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--orange); color: #fff; flex-shrink: 0;
  display: grid; place-items: center; font-size: .9rem;
  transition: background var(--t);
}
.msg-send:hover { background: #FB923C }

/* ── Notification panel ── */
.notif-panel {
  position: fixed; z-index: 2000;
  width: 320px; max-height: 420px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: none; flex-direction: column; overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.notif-head strong { font-size: .9rem }
.notif-actions { display: flex; gap: 10px; align-items: center }
.notif-mark-all {
  font-size: .75rem; color: var(--blue-lt); cursor: pointer;
  background: none; border: none; font-family: inherit;
}
.notif-mark-all:hover { text-decoration: underline }
.notif-clear { color: var(--red) }
.notif-list { overflow-y: auto; flex: 1 }
.notif-empty { padding: 24px; text-align: center; color: var(--text-2); font-size: .875rem }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.03);
  transition: background var(--t);
}
.notif-item:hover { background: rgba(255,255,255,.03) }
.notif-item.read { opacity: .5 }
.notif-dot-marker {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange); flex-shrink: 0; margin-top: 5px;
}
.notif-item.read .notif-dot-marker { background: transparent }
.notif-body p { font-size: .85rem; line-height: 1.5; margin-bottom: 3px }
.notif-time   { font-size: .72rem; color: var(--text-2) }

/* ── Finance page ── */
.fin-period-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; font-size: .875rem; color: var(--text-2);
}
.fin-period-bar select {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-1);
  font-size: .875rem; padding: 6px 10px; outline: none;
  font-family: inherit;
}
.fin-summary {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.fin-total-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px 22px; min-width: 180px;
}
.fin-total-card.orange { border-color: rgba(249,115,22,.2) }
.fin-total-card span   { display: block; font-size: .78rem; color: var(--text-2); margin-bottom: 4px }
.fin-total-card strong { font-size: 1.3rem; font-weight: 800; color: #fff }
.fin-total-card.orange strong { color: var(--orange) }
.fin-cat-pill {
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 16px;
  display: flex; flex-direction: column; gap: 3px;
}
.fin-cat-pill span   { font-size: .72rem; color: var(--text-2) }
.fin-cat-pill strong { font-size: .9rem; color: #fff; font-weight: 700 }
.cat-pill {
  display: inline-block; font-size: .72rem; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  background: rgba(2,132,199,.1); color: var(--blue-lt);
}
.adv-check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: .875rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.adv-check-row:last-child { border: none }

/* ── Role badges ── */
.badge.role-admin      { background: rgba(249,115,22,.15); color: var(--orange) }
.badge.role-manager    { background: rgba(2,132,199,.15);  color: var(--blue-lt) }
.badge.role-technician { background: rgba(16,185,129,.15); color: #34d399 }
.badge.role-support    { background: rgba(139,92,246,.15); color: #a78bfa }

/* ── Admin panel ── */
.settings-form .form-group { margin-bottom: 16px }
.settings-form button      { margin-top: 4px }

/* ── Responsive ── */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 300;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.5) }
  .ham-btn { display: flex }
  .dash-grid     { grid-template-columns: 1fr }
  .settings-grid { grid-template-columns: 1fr }
}

@media (max-width: 767px) {
  /* Spacing */
  .page-content { padding: 12px }
  .card         { padding: 16px }

  /* Stats — always 2×2 on mobile */
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px }
  .stat-body strong { font-size: 1.3rem }

  /* Constrain grid children so table-wrap can scroll inside them */
  .dash-grid > *, .dash-grid .card { min-width: 0 }

  /* Forms */
  .form-row-2, .form-row-3 { grid-template-columns: 1fr }

  /* Toolbar — stack vertically, full-width action button */
  .page-toolbar { flex-direction: column; align-items: stretch; gap: 10px }
  .page-toolbar > .btn { justify-content: center; width: 100% }

  /* Filter tabs — horizontal scroll, no wrap */
  .filter-tabs { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px;
                 -webkit-overflow-scrolling: touch; scrollbar-width: none }
  .filter-tabs::-webkit-scrollbar { display: none }
  .ftab { flex-shrink: 0; white-space: nowrap }

  /* Tab bars (finance, admin, detail modal) — horizontal scroll */
  .tab-bar, .detail-tabs { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none }
  .tab-bar::-webkit-scrollbar, .detail-tabs::-webkit-scrollbar { display: none }
  .tab, .tab-btn { flex-shrink: 0; white-space: nowrap }

  /* ── Tables → horizontal-scroll real table ── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch }
  .data-table { font-size: .8rem; white-space: nowrap }
  .data-table th { padding: 8px 10px; font-size: .68rem }
  .data-table td { padding: 9px 10px }
  .data-table tbody tr { cursor: pointer }
.logs-table td.text-truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
  .data-table td.row-actions,
  .data-table th.row-actions {
    position: sticky; right: 0; z-index: 1;
    background: var(--bg-card);
    box-shadow: -3px 0 8px rgba(0,0,0,.25);
  }

  /* Tables where actions move into a modal — hide the actions column */
  .data-table.mobile-hide-actions .row-actions,
  .data-table.mobile-hide-actions th.row-actions {
    display: none; box-shadow: none; position: static;
  }

  /* Tap targets */
  .btn-icon { width: 36px; height: 36px; font-size: .9rem }

  /* Modal → bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0 }
  .modal         { border-radius: 20px 20px 0 0; max-width: 100%; max-height: 88vh; width: 100% }
  .modal.modal-sm { max-width: 100% }
  .detail-modal  { max-width: 100%; max-height: 95vh; border-radius: 20px 20px 0 0 }

  /* Messages — single-panel on mobile */
  .msg-contacts { width: 100% }
  .msg-chat     { display: none }
  .msg-shell.chat-active .msg-contacts { display: none }
  .msg-shell.chat-active .msg-chat    { display: flex }
  .msg-back     { display: flex }

  /* Network — swap cards for table on mobile */
  .node-grid { display: none !important }
  .router-table-wrap { display: block }
  .network-header { flex-direction: column; gap: 12px }
  .network-actions { display: flex; gap: 8px; flex-wrap: wrap }
  .network-actions .btn { flex: 1; min-width: 130px; justify-content: center }

  /* Detail modal — mobile enhancements */
  .detail-modal { max-height: 92vh }
  .detail-tabs { padding: 0 8px; gap: 0 }
  .tab-btn { padding: 12px 10px; font-size: .75rem }
  .tab-btn i { display: block; font-size: 1rem; margin-bottom: 3px }
  .tab-btn span { display: none }
  .tab-panel { padding: 12px }
  .sessions-section .detail-table,
  .tab-panel .detail-table { display: block; overflow-x: auto; white-space: nowrap; width: 100% }
  .diag-tool .form-group div { flex-direction: column }
  .diag-tool .form-group div input { width: 100% }
  .diag-tool .form-group div .btn { width: 100%; justify-content: center }
  .history-controls { flex-wrap: wrap }

  /* Finance */
  .fin-period-bar { flex-wrap: wrap }
  .fin-summary {
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
    margin-bottom: 14px;
  }
  .fin-summary::-webkit-scrollbar { display: none }
  .fin-total-card,
  .fin-cat-pill {
    flex: 0 0 auto;
    min-width: 160px;
  }
  .fin-total-card { padding: 14px 16px }
  .fin-cat-pill { padding: 10px 14px; white-space: nowrap }
  .fin-total-card strong { font-size: 1.1rem }

  /* Toast — bottom of screen */
  #toastContainer { right: 12px; left: 12px; top: auto; bottom: 12px; width: auto }
  .toast          { min-width: auto }

  /* Notification panel */
  .notif-panel { width: calc(100vw - 24px) }
}

@media (max-width: 480px) {
  /* Tightest layout */
  .page-content { padding: 10px }
  .card         { padding: 12px }
  .modal-body   { padding: 16px }
  .modal-head   { padding: 14px 16px }

  /* Stats stay 2×2 even at narrowest */
  .stats-row { grid-template-columns: 1fr 1fr }
  .stat-card { padding: 12px }

  /* Smaller filter tabs */
  .ftab { padding: 5px 11px; font-size: .78rem }

  /* Network card buttons shrink */
  .router-actions .btn { font-size: .78rem; padding: 6px 10px }

  /* Quick actions keep 2-col */
  .quick-actions { grid-template-columns: 1fr 1fr }
}

/* ── Logs + SMS pages ── */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; margin: 20px auto 0; flex-wrap: wrap;
}
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 600; color: var(--text-2);
  background: var(--bg-card); border: 1px solid var(--border);
  transition: all var(--t);
  padding: 0 10px;
}
.page-btn:hover  { color: #fff; border-color: var(--blue) }
.page-btn.active { background: var(--blue); color: #fff; border-color: var(--blue) }
.page-ellipsis   { background: none; border-color: transparent; color: var(--text-3); cursor: default; pointer-events: none }
.pagination.hidden-by-mobile-pagination { display: none !important }
.mobile-pagination { margin-top: 16px }

/* Member management rows */
.member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: .875rem;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border: none }
.sb-avatar.sm { width: 28px; height: 28px; font-size: .75rem; flex-shrink: 0 }

.form-select-sm {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-1);
  font-size: .875rem; padding: 6px 10px; outline: none;
  font-family: inherit;
}

/* Color picker row (branding settings) */
.color-pick-row { display:flex; align-items:center; gap:8px; }
.color-pick-row input[type="color"] { width:44px; height:38px; padding:2px; border-radius:6px; cursor:pointer; border:1px solid rgba(255,255,255,.12); background:transparent; }
.color-pick-row input[type="text"]  { flex:1; }

/* Toolbar search form — fixed on desktop, full-width on mobile */
.toolbar-search {
  display: flex; align-items: center; gap: 6px;
  flex: 1 1 200px; max-width: 420px; min-width: 0;
}
.toolbar-search-input {
  flex: 1 1 auto; min-width: 0; height: 36px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-1);
  font-size: .875rem; line-height: 1.2; padding: 0 10px;
  font-family: inherit; box-sizing: border-box;
}
.toolbar-search-input::placeholder { color: var(--text-2) }
@media (max-width:767px) {
  .toolbar-search { max-width: 100%; flex-basis: auto }
  .toolbar-search-input { height: 36px; min-height: 0 }
}

/* ─── Network module ─────────────────────────────────────── */
.network-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:20px; flex-wrap:wrap; }
.network-actions { display:flex; gap:8px; }

.empty-state {
  text-align:center;
  padding:40px 20px;
  max-width:520px;
  margin:40px auto;
}

.router-service-areas {
  display:block;
  margin-top:4px;
  font-size:.8rem;
}

.router-down-banner {
  background:rgba(239,68,68,.1);
  border:1px solid rgba(239,68,68,.3);
  color:var(--red);
  padding:8px 12px;
  border-radius:6px;
  font-size:.875rem;
  margin:12px 0;
}

.router-metrics {
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:14px;
  font-size:.875rem;
}
.router-metrics .metric-row {
  display:grid;
  grid-template-columns:80px 1fr auto;
  gap:8px;
  align-items:center;
}
.router-metrics .metric-row > span:first-child { color:var(--text-muted); }
.metric-bar {
  height:6px;
  background:rgba(255,255,255,.06);
  border-radius:3px;
  overflow:hidden;
}
.metric-bar-fill {
  display:block;
  height:100%;
  transition:width .3s, background .3s;
}

.router-actions {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:14px;
}
.router-actions .btn { flex-shrink:0; }

/* ─── Network module: wizard ─────────────────────────────── */
.wizard-step .code-block {
  background:#0a0a14;
  border:1px solid rgba(255,255,255,.1);
  border-radius:6px;
  padding:12px;
  font-family:Menlo,Consolas,monospace;
  font-size:.78rem;
  white-space:pre-wrap;
  word-break:break-all;
  max-height:280px;
  overflow:auto;
  color:#cce;
}

/* ── Live mode ─────────────────────────────────────── */
.btn.live-active { border-color: var(--red); color: var(--red); background: rgba(239,68,68,.1); }
.btn.live-active:hover { background: rgba(239,68,68,.2); }
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  margin-right: 4px;
  vertical-align: middle;
  animation: live-pulse 1.4s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.75); }
}

/* ── Detail Modal ──────────────────────────────────────────── */
.detail-modal { max-width: 860px; width: 95vw; display: flex; flex-direction: column; max-height: 90vh; }
.detail-body  { flex: 1; overflow-y: auto; }

.detail-tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; padding: 12px 16px; color: var(--text-muted); cursor: pointer; font-size: .85rem; font-weight: 500; transition: color .15s, border-color .15s; }
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { padding: 16px 20px; }

/* Tables inside detail modal */
.detail-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.detail-table th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.detail-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.detail-table tr:last-child td { border-bottom: none; }

.detail-loading { color: var(--text-muted); font-size: .9rem; padding: 24px 0; text-align: center; }
.detail-error   { color: var(--red); font-size: .9rem; padding: 24px 0; text-align: center; }

/* Sessions section */
.sessions-section { margin-bottom: 20px; }
.sessions-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: .85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.sessions-header strong { color: var(--text); }

/* History controls */
.history-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: .85rem; }
.history-controls select { background: var(--bg-input,var(--bg)); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 4px 8px; font-size: .85rem; }
#historyContent canvas { margin-bottom: 24px; }

/* Diagnostics */
.diag-tool { padding-top: 4px; }
.diag-output { background: #0d0d0d; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; font-family: "JetBrains Mono", "Fira Code", monospace; font-size: .8rem; color: #c8f5a0; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow-y: auto; margin-top: 12px; }

/* ── Router action buttons (mobile actions modal) ── */
.router-action-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 15px 20px;
  font-size: .95rem; font-weight: 500; color: var(--text-1);
  background: none; border: none; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--t);
  font-family: inherit;
}
.router-action-btn:last-child { border-bottom: none }
.router-action-btn:hover { background: rgba(255,255,255,.04) }
.router-action-btn i { width: 20px; text-align: center; color: var(--text-2); font-size: .9rem }
.router-action-btn.danger { color: var(--red) }
.router-action-btn.danger i { color: var(--red) }

/* ── Multi-select ── */
.multi-select {
  width: 100%; background: var(--bg-up); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-1); padding: 6px 8px;
  min-height: 90px; font-size: .875rem;
}
.multi-select option { padding: 4px 6px; border-radius: 4px; }
.multi-select option:checked { background: var(--orange); color: #fff; }
.form-hint { font-size: .75rem; color: var(--text-2); margin-top: 4px; display: block; }

/* ── Clickable ID link ── */
/* Primary clickable link — orange (job #ID, etc.) */
.btn-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--orange); font-size: inherit; font-weight: 600;
  text-decoration: none;
}
.btn-link:hover { text-decoration: underline }

/* Secondary clickable link — blue-lt (titles, router names) */
.link-text {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--blue-lt); font-size: inherit; font-weight: 700;
  text-decoration: none; text-align: left;
}
.link-text:hover { text-decoration: underline }

/* ── Job detail view grid ── */
.job-detail-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 8px 16px; font-size: .9rem;
}
.job-detail-grid dt {
  color: var(--text-2); font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; align-self: start; padding-top: 2px;
}
.job-detail-grid dd { color: var(--text-1); word-break: break-word; }
.job-detail-grid .job-desc { white-space: pre-wrap; grid-column: 2; }

/* ── Job photos ── */
.photo-preview-grid,
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px }
.photo-thumb {
  width: 76px; height: 76px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); cursor: pointer;
  transition: opacity .15s;
}
.photo-thumb:hover { opacity: .85 }
.photo-upload-label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border: 2px dashed var(--border);
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-2);
  transition: border-color .2s;
}
.photo-upload-label:hover { border-color: var(--orange) }
.photo-upload-label input[type=file] { display: none }
.photo-section-head { font-size: .8rem; color: var(--text-2); margin: 12px 0 6px }

/* ── Staff online bar (staff.php) ── */
.staff-online-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: .82rem; color: var(--text-2);
}
.staff-online-bar strong { color: var(--text-1) }
.online-dot-sm {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
  box-shadow: 0 0 6px var(--green);
}
.online-chip {
  background: rgba(16,185,129,.12); color: var(--green);
  border: 1px solid rgba(16,185,129,.25);
  border-radius: 20px; padding: 2px 10px; font-size: .75rem; font-weight: 600;
}
