/* pieng styles - tree-based UI */

:root {
  --bg-0: #0d0d0d;
  --bg-1: #141414;
  --bg-2: #1a1a1a;
  --bg-3: #242424;
  --border: #333;
  --text-0: #f5f5f5;
  --text-1: #ccc;
  --text-2: #888;
  --cyan: #4ecdc4;
  --yellow: #f7dc6f;
  --green: #58d68d;
  --red: #e74c3c;
  --blue: #5dade2;
  --purple: #af7ac5;
  --mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

[data-theme="light"] {
  --bg-0: #ffffff;
  --bg-1: #f8f9fa;
  --bg-2: #e9ecef;
  --bg-3: #dee2e6;
  --border: #ced4da;
  --text-0: #212529;
  --text-1: #495057;
  --text-2: #6c757d;
  --cyan: #0d9488;
  --yellow: #d97706;
  --green: #059669;
  --red: #dc2626;
  --blue: #2563eb;
  --purple: #7c3aed;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
}

/* App layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 48px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .logo {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1rem;
  color: var(--cyan);
}

.app-header nav {
  display: flex;
  gap: 1rem;
}

.app-header nav a {
  color: var(--text-2);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  touch-action: manipulation;
}

.app-header nav a:hover { color: var(--text-0); }
.app-header nav a.active { color: var(--cyan); background: var(--bg-2); }

.status { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-2); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-dot.error { background: var(--red); }

.user-badge { font-size: 0.8rem; color: var(--text-1); }

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
}
.logout-btn:hover { border-color: var(--text-2); color: var(--text-0); }

/* Theme toggle */
.theme-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-2);
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}
[data-theme="light"] .theme-toggle::after {
  transform: translateX(16px);
  background: var(--yellow);
}

/* Header search */
.header-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.header-search .search-input {
  width: 180px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-0);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--mono);
}
.header-search .search-input:focus {
  outline: none;
  border-color: var(--cyan);
}
.header-search .search-input::placeholder {
  color: var(--text-2);
}

.header-search .search-info {
  font-size: 0.75rem;
  color: var(--text-2);
  min-width: 45px;
  font-family: var(--mono);
}

.header-search .search-nav {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.6rem;
}
.header-search .search-nav:hover {
  background: var(--bg-3);
  color: var(--text);
}

.search-toggle {
  cursor: pointer;
  padding: 2px;
  margin-right: 1.5rem;
}
.toggle-track {
  width: 24px;
  height: 12px;
  background: var(--bg-3);
  border: 1px solid var(--text-2);
  position: relative;
}
.toggle-thumb {
  width: 10px;
  height: 10px;
  background: var(--text-2);
  position: absolute;
  top: 0;
  left: 0;
  transition: left 0.15s;
}
.search-toggle.networks .toggle-thumb {
  left: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Hide search when not logged in */
body.not-authed .header-search {
  display: none;
}

/* Main content */
.main-content {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Cards */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-0);
}

/* Forms */
input, select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.9rem;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--cyan);
}

input::placeholder { color: var(--text-2); }

button {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  touch-action: manipulation; /* Prevent double-tap delay on mobile */
}

button:hover {
  background: var(--bg-3);
  border-color: var(--text-2);
}

button.primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--bg-0);
}
button.primary:hover {
  filter: brightness(1.1);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

tr:last-child td { border-bottom: none; }

/* Misc */
.mono { font-family: var(--mono); }
.sub { color: var(--text-2); font-size: 0.85rem; }
.hidden { display: none !important; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
.loading { color: var(--text-2); padding: 1rem; font-size: 0.85rem; }

/* ============================================
   TREE VIEW
   ============================================ */

.tree-card { padding: 0; }
.tree-card h2 { padding: 1.25rem 1.25rem 0.75rem; margin: 0; }

.search-match > .tree-row {
  background: color-mix(in srgb, var(--green) 20%, transparent) !important;
  box-shadow: inset 0 0 0 2px var(--green);
}

.search-match-host {
  background: color-mix(in srgb, var(--green) 25%, transparent) !important;
  box-shadow: inset 0 0 0 2px var(--green);
}

.net-tree {
  border-top: 1px solid var(--border);
}

.tree-node {
  border-bottom: 1px solid var(--border);
}
.tree-node:last-child { border-bottom: none; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  min-height: 44px;
}

.tree-row.subdivide { background: color-mix(in srgb, var(--yellow) 5%, transparent); }
.tree-row.leaf { background: color-mix(in srgb, var(--blue) 5%, transparent); }
.tree-row:hover { background: var(--bg-2); }

.tree-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  flex-shrink: 0;
  touch-action: manipulation;
}
.tree-toggle:hover { color: var(--text-0); }
.tree-toggle.leaf-dot { cursor: default; color: var(--text-2); font-size: 8px; }

.tree-cidr {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cyan);
  min-width: 140px;
  flex-shrink: 0;
}

.tree-desc {
  flex: 1;
  min-width: 0;
  color: var(--text-1);
}

.tree-desc .desc-text {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}
.tree-desc .desc-text:hover { background: var(--bg-3); }

.tree-desc .desc-edit {
  width: 100%;
  max-width: 300px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

.tree-meta {
  color: var(--text-2);
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.tree-owner {
  color: var(--purple);
  font-size: 0.8rem;
  margin-right: 0.5rem;
  min-width: 80px;
}

.tree-owner .owner-text {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 60px;
  display: inline-block;
}
.tree-owner .owner-text:empty {
  background: var(--bg-3);
  opacity: 0.5;
}
.tree-owner .owner-text:hover { background: var(--bg-3); opacity: 1; }

.tree-owner .owner-edit {
  width: 120px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.tree-account {
  color: var(--text-2);
  font-size: 0.8rem;
  margin-right: 0.5rem;
  min-width: 80px;
}

.tree-account .account-text {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 60px;
  display: inline-block;
}
.tree-account .account-text:empty {
  background: var(--bg-3);
  opacity: 0.5;
}
.tree-account .account-text:hover { background: var(--bg-3); opacity: 1; }

.tree-account .account-edit {
  width: 100px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.tree-actions {
  display: flex;
  margin-left: auto;
  flex-shrink: 0;
}

/* Action buttons - large, flush with edge */
.btn-action {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--border);
  min-width: 80px;
}

.btn-open {
  background: color-mix(in srgb, var(--yellow) 20%, var(--bg-2));
  color: var(--yellow);
}
.btn-open:hover {
  background: color-mix(in srgb, var(--yellow) 30%, var(--bg-2));
}

.btn-hosts {
  background: color-mix(in srgb, var(--blue) 20%, var(--bg-2));
  color: var(--blue);
}
.btn-hosts:hover {
  background: color-mix(in srgb, var(--blue) 30%, var(--bg-2));
}

.btn-settings {
  background: transparent;
  color: var(--text-2);
  font-size: 1rem;
  padding: 0.6rem 1rem;
  min-width: 40px;
}
.btn-settings:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

/* ============================================
   NETWORK SETTINGS PANEL
   ============================================ */

.settings-panel {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 1rem;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 1.2rem;
  padding: 0 0.5rem;
  cursor: pointer;
}
.btn-close:hover { color: var(--text-0); }

.settings-help {
  margin-bottom: 0.75rem;
}

.mask-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mask-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-1);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.mask-option:hover { background: var(--bg-3); }

.mask-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
}

.mask-label {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--cyan);
}

.mask-size {
  color: var(--text-2);
  font-size: 0.75rem;
}

.settings-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tree-children {
  border-top: 1px solid var(--border);
  background: var(--bg-0);
}

.tree-empty {
  padding: 0.75rem 1rem;
  color: var(--text-2);
  font-size: 0.85rem;
  font-style: italic;
}

/* ============================================
   ALLOCATION BAR
   ============================================ */

.alloc-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.alloc-desc {
  flex: 1;
  min-width: 150px;
  max-width: 250px;
}

.alloc-label {
  color: var(--text-2);
  font-size: 0.8rem;
}

.alloc-btns {
  display: flex;
  gap: 4px;
}

.alloc-btn {
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 0.85rem;
  border-radius: 4px;
}

.alloc-btn.preferred {
  background: var(--green);
  border-color: var(--green);
  color: var(--bg-0);
  font-weight: 600;
}
.alloc-btn.preferred:hover {
  filter: brightness(1.1);
}

.alloc-btn.other {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
.alloc-btn.other:hover {
  border-color: var(--text-2);
  color: var(--text-1);
}

/* Edit mode button */
.btn-edit-mode {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 6px 10px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  margin-left: auto;
}
.btn-edit-mode:hover {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--bg-0);
}
.btn-edit-mode.active {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--bg-0);
}

/* Available subnets panel */
.avail-subnets {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.avail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-1);
}

.avail-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.avail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
}

.avail-cidr {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--cyan);
}

.avail-item .avail-btns {
  display: flex;
  gap: 0.5rem;
}

.avail-item .avail-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-1);
}

.avail-item .avail-btn.assign {
  border-color: var(--green);
  color: var(--green);
}
.avail-item .avail-btn.assign:hover {
  background: var(--green);
  color: var(--bg-0);
}

.avail-item .avail-btn.subdiv {
  border-color: var(--cyan);
  color: var(--cyan);
}
.avail-item .avail-btn.subdiv:hover {
  background: var(--cyan);
  color: var(--bg-0);
}

/* Selected mask button */
.alloc-btn.selected {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--bg-0);
}

/* ============================================
   HOST PANEL
   ============================================ */

.host-panel {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.host-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.host-header .host-form {
  margin-bottom: 0;
  flex: 1;
}

.edit-mode-label {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--cyan);
  flex: 1;
}

.host-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.host-ip { width: 130px; }
.host-desc-input { flex: 1; min-width: 150px; max-width: 250px; }

.btn-add {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--bg-0);
}
.btn-add:hover { filter: brightness(1.1); }

.host-empty { padding: 0.5rem 0; }

.host-table { margin-top: 0.5rem; }
.host-table td { padding: 0.4rem 0.5rem; font-size: 0.85rem; }

.host-table tbody tr:nth-child(odd) { background: var(--bg-1); }
.host-table tbody tr:nth-child(even) { background: var(--bg-2); }
.host-table tbody tr:hover { background: var(--bg-3); }

.host-table tr.highlight-new {
  background: color-mix(in srgb, var(--cyan) 30%, transparent) !important;
  transition: background 0.3s ease;
}

.host-table tr.highlight-new td {
  color: var(--text-0);
}

.host-table.edit-mode tr.used:nth-child(odd) { background: color-mix(in srgb, var(--cyan) 15%, var(--bg-1)); }
.host-table.edit-mode tr.used:nth-child(even) { background: color-mix(in srgb, var(--cyan) 10%, var(--bg-2)); }
.host-table.edit-mode tr.free:nth-child(odd) { background: var(--bg-1); }
.host-table.edit-mode tr.free:nth-child(even) { background: var(--bg-2); }
.host-table.edit-mode tr:hover { background: var(--bg-3); }

.desc-input-inline {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-0);
  padding: 2px 4px;
  font-size: 0.85rem;
}
.desc-input-inline:focus {
  background: var(--bg-1);
  border-color: var(--cyan);
}
.desc-input-inline::placeholder {
  color: var(--text-2);
  font-style: italic;
}

.host-addr {
  font-family: var(--mono);
  color: var(--cyan);
  width: 140px;
}

.host-desc-cell {
  cursor: pointer;
}
.host-desc-cell .desc-text {
  padding: 2px 4px;
  border-radius: 3px;
}
.host-desc-cell .desc-text:hover { background: var(--bg-3); }
.host-desc-cell .desc-edit {
  width: 100%;
  padding: 3px 6px;
  font-size: 0.85rem;
}

.host-actions { width: 40px; text-align: right; }

.btn-del {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 3px;
  transition: all 0.15s;
}
.btn-del:hover {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

/* ============================================
   USER MANAGEMENT
   ============================================ */

.user-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.user-form input { width: 150px; }
.user-form select { width: 100px; }

.users-list { margin-top: 1rem; }

.user-actions {
  display: flex;
  gap: 0.25rem;
}

.role-select {
  padding: 3px 6px;
  font-size: 0.75rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-1);
}

.btn-sm {
  padding: 3px 8px;
  font-size: 0.75rem;
}

/* ============================================
   LOGS
   ============================================ */

.log-time { font-size: 0.8rem; color: var(--text-2); white-space: nowrap; }
.log-user { color: var(--purple); }
.log-prefix { font-family: var(--mono); color: var(--cyan); }
.log-action { color: var(--text-1); }

/* ============================================
   LOGIN
   ============================================ */

.not-authed .app-header { display: none; }

.login-card {
  max-width: 320px;
  margin: 4rem auto;
  text-align: center;
}

.login-card h2 {
  font-family: var(--mono);
  font-size: 1.5rem;
  color: var(--cyan);
  margin-bottom: 0.25rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.login-form input {
  width: 100%;
}

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  padding: 0.5rem;
  background: color-mix(in srgb, var(--red) 10%, transparent);
  border-radius: 4px;
}

/* ============================================
   ADMIN VISIBILITY
   ============================================ */

.admin-only { display: none; }
body.is-admin .admin-only { display: inline; }

/* ============================================
   TOAST
   ============================================ */

.toast-root {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  animation: slideIn 0.2s ease;
  max-width: 400px;
}

.toast.info { border-color: var(--cyan); }
.toast.warning { 
  border-color: var(--yellow); 
  background: color-mix(in srgb, var(--yellow) 15%, var(--bg-2));
  font-size: 1rem;
  padding: 1rem 1.25rem;
  border-width: 2px;
}
.toast.error { 
  border-color: var(--red); 
  background: color-mix(in srgb, var(--red) 15%, var(--bg-2)); 
  font-size: 1.1rem;
  font-weight: 500;
  padding: 1.25rem 1.5rem;
  border-width: 2px;
  box-shadow: 0 4px 20px rgba(231, 76, 60, 0.3);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   NETWORK STATUS BANNER
   ============================================ */

.network-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--red);
  color: white;
  text-align: center;
  padding: 0.75rem 1rem;
  font-weight: 600;
  z-index: 1000;
  animation: slideDown 0.3s ease;
}

.network-banner.hidden {
  display: none;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

body:has(.network-banner:not(.hidden)) .app-header {
  top: 44px;
}

/* ============================================
   WARNING MODAL
   ============================================ */

.warning-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  cursor: pointer;
}

.warning-modal {
  background: #2a1f1f;
  border: 2px solid #d9534f;
  border-radius: 8px;
  padding: 2rem 3rem;
  color: #f5c6c6;
  font-size: 1.25rem;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 8px 32px rgba(217, 83, 79, 0.4);
  max-width: 90%;
}

.warning-modal::after {
  content: '(click anywhere to dismiss)';
  display: block;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: #a88;
  font-weight: normal;
}

.confirm-modal::after {
  display: none;
}

.confirm-modal {
  cursor: default;
}

.confirm-text {
  margin-bottom: 1.5rem;
}

.confirm-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.confirm-buttons button {
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
}

.confirm-cancel {
  background: var(--bg-3);
  color: var(--text);
}

.confirm-cancel:hover {
  background: var(--bg-2);
}

.confirm-ok {
  background: #d9534f;
  color: white;
}

.confirm-ok:hover {
  background: #c9302c;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  /* Header - stack search below nav */
  .app-header {
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }
  
  .app-header nav {
    order: 1;
    gap: 0.5rem;
  }
  
  .app-header nav a {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .header-search {
    order: 3;
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }
  
  .header-search .search-input {
    flex: 1;
    min-width: 120px;
  }
  
  .header-right {
    order: 2;
    gap: 0.5rem;
  }
  
  .header-right .status {
    display: none; /* Hide status on mobile */
  }
  
  .user-badge {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Main content */
  .main-content {
    padding: 0.75rem;
  }
  
  /* Tree - horizontal scroll */
  .tree {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tree-row {
    min-width: max-content;
    padding: 0.5rem 0.25rem;
  }
  
  .tree-cidr {
    min-width: 90px;
    font-size: 0.8rem;
  }
  
  .tree-desc {
    min-width: 100px;
    max-width: 150px;
  }
  
  /* Hide owner/account on mobile - too cramped */
  .tree-owner, .tree-account {
    display: none;
  }
  
  /* Larger touch targets for buttons */
  .btn-action {
    min-width: 50px;
    min-height: 36px;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
  
  .tree-toggle {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
  }
  
  .btn-settings {
    min-width: 36px;
    min-height: 36px;
  }
  
  /* Allocation bar - stack vertically */
  .alloc-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  
  .alloc-desc {
    max-width: 100%;
    width: 100%;
  }
  
  .alloc-btns {
    flex-wrap: wrap;
  }
  
  .alloc-btns button {
    min-height: 40px;
    padding: 0.5rem 1rem;
  }
  
  /* Host panel - stack form */
  .host-header {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .host-form {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }
  
  .host-form input {
    width: 100%;
    max-width: none;
  }
  
  .host-form .btn-add {
    width: 100%;
    min-height: 40px;
  }
  
  .btn-edit-mode {
    align-self: flex-end;
  }
  
  /* Host table */
  .host-table {
    font-size: 0.85rem;
  }
  
  .host-addr {
    min-width: 90px;
  }
  
  .btn-del {
    min-width: 40px;
    min-height: 32px;
  }
  
  /* Modals - full width */
  .warning-modal, .confirm-modal {
    width: 90%;
    max-width: 90%;
    padding: 1.5rem;
    font-size: 1rem;
  }
  
  .confirm-buttons {
    flex-direction: column-reverse;
    gap: 0.75rem;
  }
  
  .confirm-buttons button {
    width: 100%;
    min-height: 44px;
  }
  
  /* Settings panel */
  .settings-panel {
    padding: 0.75rem;
  }
  
  .mask-grid {
    gap: 0.25rem;
  }
  
  .mask-option {
    min-height: 36px;
  }
  
  /* Login page */
  .login-card {
    width: 95%;
    max-width: 95%;
    padding: 1.5rem;
  }
  
  /* Users page */
  .user-form {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .user-form input, .user-form select, .user-form button {
    width: 100%;
    min-height: 40px;
  }
  
  .users-list table {
    font-size: 0.8rem;
  }
  
  .user-actions {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .role-select, .btn-sm {
    min-height: 32px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .tree-desc {
    max-width: 100px;
  }
  
  .search-info {
    display: none;
  }
  
  .search-toggle {
    margin-right: 0.5rem;
  }
}
