/* ===== TRIBAL VPS DASHBOARD — DESIGN SYSTEM ===== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Cinzel:wght@400;600;700&family=Rajdhani:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

/* ===== VARIABLES ===== */
:root {
  --bg:            #080808;
  --bg-surface:    #0E0B07;
  --bg-card:       #141008;
  --bg-elevated:   #1C1608;
  --bg-modal:      #0A0806;

  --rust:          #C4502A;
  --rust-bright:   #E06030;
  --rust-dark:     #7A2810;
  --rust-glow:     rgba(196,80,42,0.35);
  --rust-subtle:   rgba(196,80,42,0.12);

  --teal:          #1ABAB4;
  --teal-bright:   #22D4CE;
  --teal-dark:     #0E8A84;
  --teal-glow:     rgba(26,186,180,0.30);
  --teal-subtle:   rgba(26,186,180,0.10);

  --parchment:     #E8D5B0;
  --parchment-dim: #A09070;
  --parchment-dark:#5A4A30;
  --gold:          #C8A840;

  --online:        #22C55E;
  --offline:       #EF4444;
  --idle:          #F59E0B;

  --border:        rgba(196,80,42,0.25);
  --border-bright: rgba(196,80,42,0.60);
  --border-teal:   rgba(26,186,180,0.25);

  --sidebar-w:     260px;
  --header-h:      64px;
  --radius:        4px;

  --font-display:  'Cinzel Decorative', serif;
  --font-title:    'Cinzel', serif;
  --font-body:     'Rajdhani', sans-serif;
  --font-mono:     'Share Tech Mono', monospace;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--parchment);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-bright); }
input, select, textarea, button { font-family: var(--font-body); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--rust-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--rust); }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.text-rust { color: var(--rust); }
.text-teal { color: var(--teal); }
.text-gold { color: var(--gold); }
.text-dim  { color: var(--parchment-dim); }
.text-mono { font-family: var(--font-mono); }

/* ===== TRIBAL ORNAMENT CORNERS ===== */
.tribal-corners {
  position: relative;
}
.tribal-corners::before,
.tribal-corners::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-color: var(--teal);
  border-style: solid;
  pointer-events: none;
  z-index: 1;
}
.tribal-corners::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.tribal-corners::after  { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.tc-inner { position: relative; }
.tc-inner > .corner-tr,
.tc-inner > .corner-bl {
  position: absolute;
  width: 18px; height: 18px;
  border-color: var(--rust);
  border-style: solid;
  pointer-events: none;
}
.tc-inner > .corner-tr { top: -1px; right: -1px; border-width: 2px 2px 0 0; }
.tc-inner > .corner-bl { bottom: -1px; left: -1px; border-width: 0 0 2px 2px; }

/* ===== DIVIDER ===== */
.tribal-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: var(--parchment-dark);
  font-size: 11px;
  letter-spacing: 2px;
}
.tribal-divider::before,
.tribal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright), transparent);
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(196,80,42,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(26,186,180,0.06) 0%, transparent 60%),
    var(--bg);
  animation: fadeIn 0.6s ease;
}

.login-card {
  width: 420px;
  max-width: 95vw;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  padding: 40px 36px;
  position: relative;
}

.login-logo {
  text-align: center;
  margin-bottom: 8px;
}

.login-logo svg {
  width: 52px; height: 52px;
  filter: drop-shadow(0 0 8px var(--rust-glow));
}

.login-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--rust-bright);
  text-align: center;
  letter-spacing: 3px;
  text-shadow: 0 0 20px var(--rust-glow);
  margin-bottom: 4px;
}

.login-subtitle {
  font-family: var(--font-title);
  font-size: 11px;
  color: var(--teal);
  text-align: center;
  letter-spacing: 5px;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--parchment-dim);
  margin-bottom: 6px;
  font-family: var(--font-title);
}

.form-input {
  width: 100%;
  background: rgba(196,80,42,0.06);
  border: 1px solid var(--border);
  color: var(--parchment);
  padding: 10px 14px;
  font-size: 15px;
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus {
  border-color: var(--rust);
  box-shadow: 0 0 0 2px var(--rust-subtle), inset 0 0 8px rgba(196,80,42,0.05);
}
.form-input::placeholder { color: var(--parchment-dark); }

select.form-input option {
  background: var(--bg-card);
  color: var(--parchment);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23C4502A' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn-primary {
  background: linear-gradient(135deg, var(--rust-dark), var(--rust));
  color: var(--parchment);
  border: 1px solid var(--rust);
  box-shadow: 0 0 12px var(--rust-glow);
  width: 100%;
  justify-content: center;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--rust), var(--rust-bright));
  box-shadow: 0 0 20px var(--rust-glow), 0 2px 8px rgba(0,0,0,0.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-teal {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: var(--bg);
  border: 1px solid var(--teal);
  box-shadow: 0 0 10px var(--teal-glow);
}
.btn-teal:hover {
  box-shadow: 0 0 18px var(--teal-glow);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--parchment-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--rust);
  color: var(--parchment);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 11px;
  letter-spacing: 1px;
}

.btn-icon {
  padding: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--parchment-dim);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover { border-color: var(--rust); color: var(--rust); }
.btn-icon.danger:hover { border-color: var(--offline); color: var(--offline); }

.error-msg {
  color: var(--offline);
  font-size: 13px;
  text-align: center;
  margin-top: 10px;
  min-height: 20px;
}

/* ===== APP LAYOUT ===== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-logo-icon {
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}

.sidebar-logo-icon svg {
  width: 44px; height: 44px;
  filter: drop-shadow(0 0 8px var(--rust-glow));
  animation: compassSpin 20s linear infinite;
}

@keyframes compassSpin {
  0%   { filter: drop-shadow(0 0 6px var(--rust-glow)); }
  50%  { filter: drop-shadow(0 0 14px var(--rust-glow)) drop-shadow(0 0 6px var(--teal-glow)); }
  100% { filter: drop-shadow(0 0 6px var(--rust-glow)); }
}

.sidebar-brand {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--rust-bright);
  letter-spacing: 2px;
  line-height: 1.3;
  text-shadow: 0 0 12px var(--rust-glow);
}

.sidebar-brand-sub {
  font-family: var(--font-title);
  font-size: 9px;
  color: var(--teal);
  letter-spacing: 4px;
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section-label {
  font-family: var(--font-title);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--parchment-dark);
  padding: 12px 20px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--parchment-dim);
  text-transform: uppercase;
  user-select: none;
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.nav-item:hover {
  color: var(--parchment);
  background: var(--rust-subtle);
  border-left-color: var(--rust-dark);
}

.nav-item.active {
  color: var(--rust-bright);
  background: rgba(196,80,42,0.15);
  border-left-color: var(--rust-bright);
  text-shadow: 0 0 8px var(--rust-glow);
}

.nav-item.active svg {
  filter: drop-shadow(0 0 4px var(--rust-glow));
}

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--parchment-dim);
}

/* ===== STATUS DOTS ===== */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--online); box-shadow: 0 0 6px var(--online); animation: pulseGreen 2s infinite; }
.status-dot.offline { background: var(--offline); }
.status-dot.idle    { background: var(--idle); box-shadow: 0 0 6px var(--idle); animation: pulseAmber 2s infinite; }
.status-dot.unknown { background: var(--parchment-dark); }

@keyframes pulseGreen {
  0%,100% { box-shadow: 0 0 4px var(--online); }
  50%      { box-shadow: 0 0 12px var(--online), 0 0 20px rgba(34,197,94,0.4); }
}
@keyframes pulseAmber {
  0%,100% { box-shadow: 0 0 4px var(--idle); }
  50%      { box-shadow: 0 0 12px var(--idle); }
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--parchment);
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-ornament {
  color: var(--rust);
  font-size: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--parchment-dim);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-title);
  letter-spacing: 1px;
}

.header-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--teal);
}

/* ===== VIEW CONTAINER ===== */
.view-container {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

.view { animation: fadeInUp 0.35s ease; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--parchment);
}

.page-subtitle {
  font-size: 12px;
  color: var(--parchment-dim);
  letter-spacing: 2px;
  margin-top: 2px;
}

/* ===== STAT CARDS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  border-color: var(--rust);
  box-shadow: 0 0 16px var(--rust-glow);
}

.stat-card-icon {
  width: 36px; height: 36px;
  margin-bottom: 12px;
  color: var(--rust);
  opacity: 0.85;
}

.stat-label {
  font-family: var(--font-title);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--parchment-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--parchment);
  line-height: 1;
  margin-bottom: 12px;
}

.stat-value .stat-unit {
  font-size: 14px;
  color: var(--parchment-dim);
  margin-left: 4px;
}

.progress-bar {
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill.rust {
  background: linear-gradient(90deg, var(--rust-dark), var(--rust-bright));
}

.progress-fill.teal {
  background: linear-gradient(90deg, var(--teal-dark), var(--teal-bright));
}

.progress-fill.gold {
  background: linear-gradient(90deg, #8A6010, var(--gold));
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
  0%   { left: -100%; }
  100% { left: 200%; }
}

.stat-meta {
  font-size: 11px;
  color: var(--parchment-dim);
  margin-top: 6px;
  font-family: var(--font-mono);
}

/* Bots card special */
.bots-count {
  color: var(--teal);
  text-shadow: 0 0 12px var(--teal-glow);
}

/* ===== UPTIME / NETWORK ROW ===== */
.info-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.info-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.info-chip-label {
  font-family: var(--font-title);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--parchment-dim);
}

.info-chip-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--teal);
}

/* ===== BOTS TABLE ===== */
.section-header {
  font-family: var(--font-title);
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--rust);
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== TABLE ===== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-elevated);
  font-family: var(--font-title);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--rust);
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid rgba(196,80,42,0.08);
  transition: background 0.15s;
}
tbody tr:hover { background: rgba(196,80,42,0.05); }
tbody tr:last-child { border-bottom: none; }

td {
  padding: 12px 16px;
  color: var(--parchment);
  vertical-align: middle;
}

td.dim { color: var(--parchment-dim); font-size: 12px; }

.app-link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--teal);
  display: flex;
  align-items: center;
  gap: 4px;
}
.app-link:hover { color: var(--teal-bright); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-family: var(--font-title);
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-online  { background: rgba(34,197,94,0.15);  color: var(--online);  border: 1px solid rgba(34,197,94,0.3);  }
.badge-offline { background: rgba(239,68,68,0.15);  color: var(--offline); border: 1px solid rgba(239,68,68,0.3);  }
.badge-idle    { background: rgba(245,158,11,0.15); color: var(--idle);    border: 1px solid rgba(245,158,11,0.3); }
.badge-unknown { background: rgba(160,144,112,0.1); color: var(--parchment-dim); border: 1px solid var(--border); }
.badge-paid    { background: rgba(34,197,94,0.15);  color: var(--online);  border: 1px solid rgba(34,197,94,0.3);  }
.badge-unpaid  { background: rgba(196,80,42,0.15);  color: var(--rust);    border: 1px solid var(--border-bright); }
.badge-overdue { background: rgba(239,68,68,0.15);  color: var(--offline); border: 1px solid rgba(239,68,68,0.3);  }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--parchment);
  padding: 9px 14px;
  font-size: 14px;
  border-radius: var(--radius);
  outline: none;
  font-family: var(--font-body);
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--rust); }
.search-input::placeholder { color: var(--parchment-dark); }

/* ===== MINI BARS ===== */
.mini-bar-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 80px; }
.mini-bar-label { font-size: 10px; color: var(--parchment-dim); font-family: var(--font-mono); display: flex; justify-content: space-between; }
.mini-bar { height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 2px; }
.mini-bar-fill.cpu  { background: var(--rust); }
.mini-bar-fill.mem  { background: var(--teal); }

/* ===== CLIENT CARDS ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.client-card:hover {
  border-color: var(--rust-dark);
  box-shadow: 0 0 14px rgba(196,80,42,0.15);
}

.client-name {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--parchment);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.client-company {
  font-size: 12px;
  color: var(--teal);
  letter-spacing: 1px;
  margin-bottom: 12px;
  font-family: var(--font-title);
}

.client-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--parchment-dim);
  margin-bottom: 6px;
}

.client-info-row svg { width: 13px; height: 13px; color: var(--rust); flex-shrink: 0; }

.app-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.app-chip {
  background: var(--teal-subtle);
  border: 1px solid var(--border-teal);
  color: var(--teal);
  padding: 3px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  border-radius: var(--radius);
  font-family: var(--font-title);
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ===== BILLING SUMMARY ===== */
.billing-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.billing-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 18px 20px;
  text-align: center;
}

.billing-stat-val {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--parchment);
  margin-bottom: 4px;
}
.billing-stat-val.green { color: var(--online); text-shadow: 0 0 8px rgba(34,197,94,0.4); }
.billing-stat-val.red   { color: var(--offline); text-shadow: 0 0 8px rgba(239,68,68,0.3); }
.billing-stat-val.gold  { color: var(--gold); }

.billing-stat-label {
  font-family: var(--font-title);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--parchment-dim);
  text-transform: uppercase;
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-bright);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: fadeInUp 0.25s ease;
}

.modal-lg { max-width: 720px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 16px;
  letter-spacing: 3px;
  color: var(--rust-bright);
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--parchment-dim);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 16px;
  transition: all 0.2s;
}
.modal-close:hover { border-color: var(--rust); color: var(--rust); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Multi-select apps checkboxes */
.app-checkbox-list {
  border: 1px solid var(--border);
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.app-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(196,80,42,0.07);
  cursor: pointer;
  transition: background 0.15s;
}
.app-checkbox-item:last-child { border-bottom: none; }
.app-checkbox-item:hover { background: var(--rust-subtle); }
.app-checkbox-item input[type=checkbox] { accent-color: var(--rust); }
.app-checkbox-item label { cursor: pointer; font-size: 13px; }

/* Invoice line items */
.invoice-items-list { margin-bottom: 12px; }

.invoice-item-row {
  display: grid;
  grid-template-columns: 1fr 110px 60px 90px 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.invoice-item-row .form-input { padding: 7px 10px; font-size: 13px; }

.invoice-total-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 15px;
}

.invoice-total-val {
  color: var(--rust-bright);
  font-size: 20px;
  font-weight: 700;
  text-shadow: 0 0 8px var(--rust-glow);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--parchment-dark);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; display: block; opacity: 0.4; }
.empty-state h3 { font-family: var(--font-title); letter-spacing: 3px; font-size: 14px; margin-bottom: 6px; color: var(--parchment-dim); }
.empty-state p { font-size: 13px; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  color: var(--parchment);
  padding: 12px 20px;
  font-size: 13px;
  font-family: var(--font-title);
  letter-spacing: 1px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: slideInRight 0.3s ease;
  min-width: 260px;
}

.toast.success { border-color: var(--online); }
.toast.error   { border-color: var(--offline); }
.toast.info    { border-color: var(--teal); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== LOADING SPINNER ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--rust);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TRIBAL BORDER PATTERN ===== */
.tribal-frame {
  position: relative;
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
}
.tribal-frame::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(26,186,180,0.15);
  pointer-events: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .view-container { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .invoice-item-row { grid-template-columns: 1fr; }
}

/* ===== DISCOVER GRID ===== */
.discover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}

.discover-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: var(--radius);
}
.discover-item:hover {
  border-color: var(--teal);
  background: var(--teal-subtle);
}
.discover-item.selected {
  border-color: var(--rust);
  background: var(--rust-subtle);
}

.discover-port {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--teal);
  font-weight: 700;
}
.discover-name { font-size: 12px; color: var(--parchment-dim); margin-top: 2px; }

/* ===== APP POWER TOGGLE ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(239,68,68,0.18);
  border: 1px solid var(--offline);
  border-radius: 22px;
  transition: 0.25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: var(--offline);
  border-radius: 50%;
  transition: 0.25s;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(34,197,94,0.18);
  border-color: var(--online);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: var(--online);
  box-shadow: 0 0 6px var(--online);
}
.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.3;
  cursor: not-allowed;
}
.toggle-switch.busy .toggle-slider { opacity: 0.5; cursor: wait; }

/* ===== TERMINAL VIEW ===== */
#view-terminal {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - 56px);
  min-height: 480px;
}
#view-terminal .page-header { flex-shrink: 0; }

.terminal-wrapper {
  flex: 1;
  background: #050505;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 6px 8px;
  position: relative;
}
.terminal-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal-subtle), transparent 60%) border-box;
  pointer-events: none;
}
#terminal-container {
  width: 100%;
  height: 100%;
}
#terminal-container .xterm { height: 100%; }
#terminal-container .xterm-viewport { overflow-y: auto !important; }

.terminal-status-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--parchment-dark);
}
#term-conn-dot { transition: background 0.3s; }
