:root {
  --bg: #0e1117;
  --bg-panel: #161b22;
  --bg-elevated: #1c2129;
  --border: #2a323d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --tx: #3fb950;
  --rx: #58a6ff;
  --warn: #d29922;
  --danger: #f85149;
  --ok: #3fb950;
  --font: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  background:
    radial-gradient(1200px 500px at 10% -10%, #1a2332 0%, transparent 55%),
    radial-gradient(900px 400px at 90% 0%, #132018 0%, transparent 50%),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--tx), var(--rx));
  box-shadow: 0 0 12px rgba(63, 185, 80, 0.45);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.topbar-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pill {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
}

.pill-ok { color: var(--ok); border-color: rgba(63, 185, 80, 0.35); }
.pill-warn { color: var(--warn); border-color: rgba(210, 153, 34, 0.35); }
.pill-danger { color: var(--danger); border-color: rgba(248, 81, 73, 0.35); }
.pill-muted { color: var(--text-dim); }

.topbar-btn {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  cursor: pointer;
}

.topbar-btn:hover {
  border-color: rgba(88, 166, 255, 0.45);
  color: var(--text);
}

.topbar-btn.is-on {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.45);
  background: rgba(210, 153, 34, 0.1);
}

.page {
  width: 100%;
}

.gauges-board {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  padding: 1rem 1rem 0;
  width: 100%;
  align-items: flex-start;
}

.gauge-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 100%;
}

.gauge-card.is-resized {
  flex: 0 0 auto;
}

.gauge-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.gauge-card-iface {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gauge-card-dir {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.gauge-card-dir.tx {
  color: var(--tx);
  border-color: rgba(63, 185, 80, 0.35);
  background: rgba(63, 185, 80, 0.08);
}

.gauge-card-dir.rx {
  color: var(--rx);
  border-color: rgba(88, 166, 255, 0.35);
  background: rgba(88, 166, 255, 0.08);
}

.gauge-card-body {
  padding: 0.35rem 0.5rem 0;
  display: flex;
  justify-content: center;
  background: #12161c;
}

.gauge-card-body .gauge-svg {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
}

.gauge-card.is-resized .gauge-card-body .gauge-svg {
  max-width: none;
  max-height: 100%;
}

.gauge-card-foot {
  padding: 0.35rem 0.75rem 0.55rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  background: #12161c;
  border-top: 1px solid transparent;
}

.gauge-track {
  stroke: #2a323d;
}

.gauge-hub {
  fill: #e6edf3;
}

.gauge-readout {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

.gauge-pct {
  font-family: var(--font);
  font-size: 9px;
  fill: var(--text-dim);
}

.dashboard {
  padding: 1rem 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
  max-width: none;
  margin: 0;
  align-items: flex-start;
}

@media (min-width: 1100px) {
  .dashboard {
    padding: 1rem 1.25rem 1.25rem;
    gap: 1.25rem;
  }

  .gauges-board {
    padding: 1rem 1.25rem 0;
  }

  .iface-card:not(.is-resized) {
    flex: 1 1 calc(50% - 0.65rem);
  }
}

.hint {
  color: var(--text-dim);
  text-align: center;
  margin: 3rem 0;
}

.iface-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 480px;
  min-width: 320px;
  max-width: 100%;
  position: relative;
}

.iface-card.is-resized {
  flex: 0 0 auto;
}

.iface-card.is-resized.has-fixed-height .torch-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.iface-card.is-resized.has-fixed-height .table-scroll {
  flex: 1;
  max-height: none;
  min-height: 80px;
}

.gauge-card.is-resized.has-fixed-height .gauge-card-body {
  flex: 1;
  align-items: center;
}

.iface-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.history-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.65rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #12161c;
}

.iface-card.is-history {
  outline: 1px solid rgba(210, 153, 34, 0.35);
}

.iface-card.is-history .history-bar {
  background: rgba(210, 153, 34, 0.06);
}

.history-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.history-field input {
  font: inherit;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.28rem 0.4rem;
  color-scheme: dark;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.hist-btn {
  font: inherit;
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.32rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  cursor: pointer;
}

.hist-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(88, 166, 255, 0.4);
}

.hist-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.hist-btn-primary {
  color: var(--rx);
  border-color: rgba(88, 166, 255, 0.4);
}

.hist-btn-live.is-on,
.iface-card:not(.is-history) .hist-btn-live:disabled {
  /* live default */
}

.iface-card.is-history .hist-btn-live:not(:disabled) {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.4);
}

.history-status {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: auto;
}

.iface-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  font-family: var(--mono);
}

.rates {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.rate-tx { color: var(--tx); }
.rate-rx { color: var(--rx); }
.rate-label {
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  margin-right: 0.35rem;
}

.chart-wrap {
  padding: 0.75rem 1rem 0.25rem;
  height: 180px;
  position: relative;
}

.chart-brush {
  position: absolute;
  top: 0.75rem;
  bottom: 1.4rem;
  background: rgba(88, 166, 255, 0.18);
  border: 1px solid rgba(88, 166, 255, 0.55);
  pointer-events: none;
  z-index: 2;
  border-radius: 2px;
}

.brush-hint {
  margin: 0;
  padding: 0.15rem 0 0.35rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.02em;
}

.chart-wrap.is-brushing {
  user-select: none;
}

.chart-wrap.is-brushing canvas {
  cursor: col-resize;
}

.chart-wrap canvas {
  cursor: crosshair;
}

.torch-wrap {
  padding: 0 1rem 1rem;
}

.torch-title {
  margin: 0.5rem 0 0.6rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-scroll {
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

table.torch {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: var(--mono);
}

table.torch th,
table.torch td {
  padding: 0.4rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.torch th {
  position: sticky;
  top: 0;
  background: #12161c;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

table.torch tbody tr:hover {
  background: rgba(88, 166, 255, 0.06);
}

table.torch .num { text-align: right; }
table.torch .tx { color: var(--tx); }
table.torch .rx { color: var(--rx); }
table.torch .idle { opacity: 0.45; }

.empty-flows {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 0.75rem 0;
}

@media (max-width: 720px) {
  .chart-wrap { height: 150px; }
  .table-scroll { max-height: 260px; }
  .resize-handle { display: none !important; }
}

/* --- Resizable card handles --- */
.resizable-card {
  position: relative;
}

.resize-handle {
  position: absolute;
  z-index: 5;
  background: transparent;
  transition: background 0.12s ease;
}

.resize-handle:hover,
.is-resizing .resize-handle {
  background: rgba(88, 166, 255, 0.35);
}

.resize-handle-e {
  top: 8px;
  right: 0;
  bottom: 14px;
  width: 6px;
  cursor: ew-resize;
}

.resize-handle-s {
  left: 8px;
  right: 14px;
  bottom: 0;
  height: 6px;
  cursor: ns-resize;
}

.resize-handle-se {
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  border-radius: 0 0 10px 0;
}

.resize-handle-se::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  opacity: 0.55;
}

body.is-card-resizing {
  user-select: none;
  cursor: var(--resize-cursor, nwse-resize) !important;
}

body.is-card-resizing * {
  cursor: inherit !important;
}

body.is-card-resizing[data-resize-cursor="ew-resize"] {
  --resize-cursor: ew-resize;
}

body.is-card-resizing[data-resize-cursor="ns-resize"] {
  --resize-cursor: ns-resize;
}

body.is-card-resizing[data-resize-cursor="nwse-resize"] {
  --resize-cursor: nwse-resize;
}

/* --- Login (professional NOC-style) --- */
body.login-page {
  --login-green: #12b981;
  --login-green-dim: rgba(18, 185, 129, 0.18);
  --login-glass: rgba(12, 16, 24, 0.72);
  --login-glass-border: rgba(255, 255, 255, 0.1);
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 1.5rem 1.25rem 2rem;
  overflow-x: hidden;
  font-family: "Manrope", var(--font);
  background: #06080d;
}

body.login-page::before {
  content: none;
}

.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    url("/img/login-bg.png") center center / cover no-repeat;
  transform: scale(1.04);
  animation: login-bg-drift 28s ease-in-out infinite alternate;
}

.login-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 50% at 50% 45%, rgba(8, 20, 16, 0.15), transparent 70%),
    linear-gradient(180deg, rgba(4, 6, 10, 0.55) 0%, rgba(4, 6, 10, 0.35) 40%, rgba(4, 6, 10, 0.72) 100%),
    radial-gradient(ellipse 90% 70% at 50% 50%, transparent 35%, rgba(0, 0, 0, 0.55) 100%);
}

@keyframes login-bg-drift {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to { transform: scale(1.08) translate3d(-1.2%, 0.6%, 0); }
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-tagline {
  position: relative;
  z-index: 3;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: clamp(0.78rem, 1.6vw, 0.95rem);
  line-height: 1.55;
  animation: login-rise 0.7s ease both;
}

.login-tagline span {
  display: block;
  color: #f3f6fa;
}

.login-tagline span:last-child {
  color: var(--login-green);
}

.login-stage {
  position: relative;
  z-index: 3;
  width: min(100%, 440px);
  animation: login-rise 0.75s ease 0.08s both;
}

.login-card {
  width: 100%;
  padding: 0;
  border: 1px solid var(--login-glass-border);
  border-radius: 18px;
  background: var(--login-glass);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.login-card-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.35rem 1.45rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.login-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #d7ffe9;
  background: linear-gradient(145deg, #14965f, #0d7a4d);
  box-shadow: 0 8px 20px rgba(18, 185, 129, 0.28);
  flex-shrink: 0;
}

.login-card-head h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}

.login-card-head p {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: #9aa3af;
}

.login-card-body {
  padding: 1.35rem 1.45rem 1.2rem;
}

.login-card-body h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-lead {
  margin: 0.4rem 0 1.25rem;
  color: #9aa3af;
  font-size: 0.88rem;
  line-height: 1.45;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e8edf3;
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 0.85rem;
  color: #7d8794;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.login-form input {
  width: 100%;
  padding: 0.78rem 2.6rem 0.78rem 2.55rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(8, 11, 16, 0.72);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
}

.login-form input::placeholder {
  color: #6b7480;
}

.login-form input:focus {
  outline: none;
  border-color: rgba(18, 185, 129, 0.65);
  box-shadow: 0 0 0 3px var(--login-green-dim);
}

.login-eye {
  position: absolute;
  right: 0.45rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: #7d8794;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.login-eye:hover {
  color: #d7dde5;
  background: rgba(255, 255, 255, 0.05);
}

.login-error {
  margin: 0;
  color: #ff7b72;
  font-size: 0.85rem;
  font-weight: 600;
}

.login-submit {
  margin-top: 0.15rem;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #1ad090 0%, #12b981 100%);
  color: #04140e;
  font: inherit;
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(18, 185, 129, 0.28);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.login-submit:hover {
  filter: brightness(1.06);
}

.login-submit:active {
  transform: translateY(1px);
}

.login-card-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.85rem 1rem 1.15rem;
  color: #7a8490;
  font-size: 0.75rem;
  font-weight: 500;
}

@media (max-width: 560px) {
  body.login-page {
    padding: 1.1rem 0.9rem 1.5rem;
    justify-content: flex-start;
    padding-top: 12vh;
  }

  .login-tagline {
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    margin-bottom: 0.25rem;
  }

  .login-card-head,
  .login-card-body {
    padding-left: 1.15rem;
    padding-right: 1.15rem;
  }
}

