/* SpeedyNET NIMS — dark charcoal sidebar, light content, green accents */
:root {
  --sn-sidebar: #1f2329;
  --sn-sidebar-2: #2a2f37;
  --sn-sidebar-text: #aeb6c1;
  --sn-green: #16a34a;
  --sn-green-2: #22c55e;
  --sn-bg: #f3f5f7;
  --sn-border: #e3e7ec;
  --sidebar-w: 250px;
  --bs-font-sans-serif: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
body { background: var(--sn-bg); color: #1f2937; font-size: .925rem; }
a { color: #15803d; }
a:hover { color: #166534; }
.btn-success { background: var(--sn-green); border-color: var(--sn-green); }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-outline-success { color: var(--sn-green); border-color: var(--sn-green); }
.btn-outline-success:hover { background: var(--sn-green); border-color: var(--sn-green); }
.form-control:focus, .form-select:focus { border-color: var(--sn-green-2); box-shadow: 0 0 0 .2rem rgba(34,197,94,.18); }
.page-link { color: #166534; }
.active > .page-link, .page-link.active { background: var(--sn-green); border-color: var(--sn-green); }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sn-sidebar); color: var(--sn-sidebar-text); position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column; z-index: 1040; transition: transform .25s ease; }
.sidebar nav { overflow-y: auto; flex: 1; padding: .5rem .6rem 1rem; }
.sidebar .brand { display: flex; align-items: center; gap: .7rem; padding: 1.05rem 1.1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar .brand small { display: block; font-size: .7rem; color: var(--sn-sidebar-text); letter-spacing: .03em; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--sn-green), #0f766e); display: grid; place-items: center; color: #fff; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: #fff; }
.nav-group { font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; color: #6b7480; padding: 1rem .7rem .35rem; }
.sidebar .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--sn-sidebar-text); padding: .5rem .7rem; border-radius: 8px; font-size: .88rem; }
.sidebar .nav-link i { width: 18px; text-align: center; opacity: .85; }
.sidebar .nav-link:hover { background: var(--sn-sidebar-2); color: #fff; }
.sidebar .nav-link.active { background: rgba(34,197,94,.14); color: #4ade80; }
.sidebar .nav-link.active i { color: #4ade80; }
.sidebar-foot { padding: .7rem 1.1rem; font-size: .7rem; color: #5b6470; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-backdrop { display: none; }
.app-main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; background: #fff; border-bottom: 1px solid var(--sn-border); display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; }
.topbar-search { position: relative; flex: 1; max-width: 560px; }
.topbar-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #9aa3ae; }
.topbar-search input { padding-left: 2.2rem; background: var(--sn-bg); border-color: transparent; border-radius: 999px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--sn-green); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: .85rem; }
.content { padding: 1.25rem; flex: 1; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }
  .app-main { margin-left: 0; }
  .content { padding: .85rem; }
}

/* Cards and headings */
.card { border: 1px solid var(--sn-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--sn-border); border-radius: 12px 12px 0 0 !important; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.stat-card { padding: 1rem 1.1rem; display: flex; align-items: center; gap: .9rem; height: 100%; }
.stat-card .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-card .value { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-card .label { font-size: .78rem; color: #6b7280; }
.stat-card a.stretched-link { color: inherit; }
.ic-green { background: #dcfce7; color: #15803d; } .ic-blue { background: #dbeafe; color: #1d4ed8; } .ic-red { background: #fee2e2; color: #b91c1c; }
.ic-purple { background: #ede9fe; color: #6d28d9; } .ic-orange { background: #ffedd5; color: #c2410c; } .ic-cyan { background: #cffafe; color: #0e7490; }
.ic-slate { background: #e2e8f0; color: #334155; } .ic-yellow { background: #fef9c3; color: #a16207; }

/* Tables */
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; background: #f9fafb; white-space: nowrap; }
.filter-bar { padding: .85rem; }
@media (max-width: 767.98px) {
  .data-table thead { display: none; }
  .data-table tr { display: block; border-bottom: 1px solid var(--sn-border); padding: .5rem 0; }
  .data-table td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem .9rem; }
  .data-table td::before { content: attr(data-label); font-weight: 600; color: #6b7280; font-size: .78rem; }
  .data-table td.text-end::before { content: ""; }
}

/* Detail list */
.detail-list dt { font-weight: 500; color: #6b7280; font-size: .85rem; padding: .35rem 0; }
.detail-list dd { padding: .35rem 0; margin: 0; border-bottom: 1px dashed #eef0f3; word-break: break-word; }
.secret-value { letter-spacing: .1em; }

/* Maps */
.location-picker, .mini-map { height: 300px; border-radius: 10px; border: 1px solid var(--sn-border); }
.mini-map { height: 220px; }
.map-pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.map-pin i { transform: rotate(45deg); color: #fff; font-size: 12px; }
.map-pin.dim { opacity: .55; }
body.full-map .content { padding: 0; position: relative; }
#networkMap { position: absolute; inset: 0; }
.map-panel { position: absolute; top: 12px; left: 12px; z-index: 800; width: 320px; max-height: calc(100% - 24px); overflow-y: auto; background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.map-panel .legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.map-coords { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 800; background: rgba(31,35,41,.88); color: #fff; font-size: .78rem; padding: .3rem .7rem; border-radius: 999px; font-family: monospace; }
.map-panel-toggle { position: absolute; top: 12px; left: 12px; z-index: 801; display: none; }
@media (max-width: 767.98px) {
  .map-panel { width: calc(100% - 24px); max-height: 55%; }
  .map-panel.collapsed { display: none; }
  .map-panel-toggle { display: block; }
}
.popup-thumb { width: 100%; max-height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: .4rem; }
.leaflet-popup-content { margin: 10px 12px; min-width: 220px; }
.nearby-item { cursor: pointer; }
.nearby-item:hover { background: #f0fdf4; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.photo-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #e5e7eb; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.photo-item:hover img { transform: scale(1.05); }
.photo-del { position: absolute; top: 4px; right: 4px; }

/* Splitter ports */
.port-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
.port { border-radius: 10px; padding: .55rem .6rem; border: 1px solid; text-decoration: none; display: block; font-size: .78rem; line-height: 1.25; }
.port .num { font-weight: 700; font-size: .95rem; }
.port-Available { background: #f0fdf4; border-color: #86efac; color: #166534; }
.port-Occupied { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.port-Reserved { background: #fefce8; border-color: #fde047; color: #854d0e; }
.port-Faulty { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.port:hover { filter: brightness(.97); }
.core-chip { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); vertical-align: middle; }

/* Trace tree */
.trace-tree { list-style: none; padding-left: 1.1rem; border-left: 2px solid #d1fae5; margin: .25rem 0 .25rem .4rem; }
.trace-tree li { margin: .35rem 0; }
.trace-edge { font-size: .72rem; color: #6b7280; font-family: monospace; }
#graph { height: 640px; background: #fff; border-radius: 0 0 12px 12px; }

/* History */
.history-list { max-height: 520px; overflow-y: auto; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #1f3a2b 0, var(--sn-sidebar) 55%); padding: 1rem; }
.auth-card { width: 100%; max-width: 410px; border: 0; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }

.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--sn-bg) 30%); padding-top: 1rem; z-index: 5; }

/* Print */
@media print {
  .sidebar, .topbar, .no-print, .sticky-actions, .btn, .toast-container { display: none !important; }
  .app-main { margin: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none; break-inside: avoid; }
  .col-xl-8, .col-xl-4 { width: 100% !important; }
  body { background: #fff; font-size: 11pt; }
  a { color: #000; text-decoration: none; }
}
body.full-map .app-main { height: 100vh; }
body.full-map .content { overflow: hidden; }
body.full-map .content > .alert { position: absolute; top: 10px; right: 10px; z-index: 900; max-width: 420px; }
