/* ========================================================================
   DevLink Cloud — Shared Stylesheet
   Modern, responsive design system for all pages
   ======================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Primary palette */
  --color-primary: #1a3152;
  --color-primary-light: #264573;
  --color-primary-dark: #0f1f35;
  --color-primary-hover: #1e5bb8;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;

  /* Status colors */
  --color-success: #22c55e;
  --color-success-bg: #dcfce7;
  --color-danger: #ef4444;
  --color-danger-bg: #fee2e2;
  --color-danger-hover: #dc2626;
  --color-warning: #f59e0b;
  --color-warning-bg: #fef3c7;
  --color-info: #3b82f6;

  /* Neutrals */
  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-surface-hover: #f8fafc;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;

  /* Typography */
  --font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Borders */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Layout */
  --top-bar-height: 56px;
  --sidebar-min-width: 340px;
  --container-max: 1200px;
}


/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--color-accent-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Typography --- */
h1, h2, h3, h4, h5 {
  color: var(--color-primary);
  font-weight: 600;
  line-height: 1.3;
}
h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }

p {
  color: var(--color-text-secondary);
}

/* --- Top Bar --- */
.top-bar {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: white;
  padding: 0 var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: var(--font-size-md);
  height: var(--top-bar-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.top-bar a {
  color: rgba(255, 255, 255, 0.8);
  transition: color var(--transition-fast);
}
.top-bar a:hover {
  color: white;
}


/* --- Sidebar Toggle (Hamburger) --- */
.toggle-sidebar {
  cursor: pointer;
  font-size: 1.3rem;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  user-select: none;
  line-height: 1;
}
.toggle-sidebar:hover {
  background: rgba(255, 255, 255, 0.15);
}


/* --- Layout: Sidebar + Main --- */
.layout {
  display: flex;
  height: calc(100vh - var(--top-bar-height));
  position: relative;
  overflow: hidden;
}

.sidebar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: fit-content;
  min-width: var(--sidebar-min-width);
  max-width: 90vw;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: var(--space-4);
  transition: transform var(--transition-base);
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

.sidebar.hidden {
  transform: translateX(-100%);
  box-shadow: none;
}

.main {
  width: 100%;
  transition: margin-left var(--transition-base);
  overflow: auto;
}

#iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: none;
}


/* --- Sidebar Buttons --- */
.sidebar-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-buttons form {
  display: contents;
}

.sidebar-btn {
  height: 38px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  padding: 0 var(--space-3);
}

.sidebar-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.sidebar-btn.logout-btn {
  background: var(--color-text-secondary);
}
.sidebar-btn.logout-btn:hover {
  background: var(--color-danger);
}


/* --- Container --- */
.container {
  width: 95%;
  max-width: var(--container-max);
  margin: var(--space-6) auto;
  background: var(--color-surface);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.container-sm {
  max-width: 600px;
}

.container-xs {
  max-width: 440px;
}


/* --- Buttons --- */
.btn,
button:not(.toggle-sidebar):not(.name-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.5;
  white-space: nowrap;
}

.btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.5;
}

.btn:hover,
.button:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-sm {
  font-size: var(--font-size-xs);
  padding: var(--space-1) var(--space-2);
}

.btn-icon {
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--font-size-md);
}

.btn-icon:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-icon img {
  height: auto;
  width: 1.3em;
}

.btn-success {
  background: var(--color-success) !important;
  color: white !important;
  border: 1px solid var(--color-success) !important;
}
.btn-success:hover {
  filter: brightness(0.9);
}

.btn-outline-secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-danger,
.btn-delete {
  background: var(--color-danger);
  color: white;
  border: 1px solid var(--color-danger);
}
.btn-danger:hover,
.btn-delete:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

.btn-secondary {
  background: var(--color-text-secondary);
  color: white;
}
.btn-secondary:hover {
  background: #475569;
}

.btn-purple {
  background: #4338ca;
  color: white;
}
.btn-purple:hover {
  background: #3730a3;
}

.button-link {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}
.button-link:hover {
  background: var(--color-primary-hover);
  color: white;
}


/* --- Form Elements --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  outline: none;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.form-group {
  margin-bottom: var(--space-4);
}

.filter-form,
.filter-box {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-4);
}

.filter-form input,
.filter-form select,
.filter-box input,
.filter-box select {
  flex: 1;
  min-width: 150px;
}


/* --- Tables --- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
}

thead th {
  background: var(--color-bg);
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-3) var(--space-3);
  text-align: center;
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

tbody td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border-light);
  text-align: center;
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--color-surface-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Filter row in table */
.filter-row th {
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.filter-row input,
.filter-row select {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-xs);
}

.filter-row button {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
}

/* Category row */
.category-row td,
tr.category-row td {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-primary);
  text-align: left;
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid var(--color-border);
}


/* --- Status Indicators --- */
.status-text {
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.status-text.online {
  color: var(--color-success);
  background: var(--color-success-bg);
}

.status-text.offline {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.alarm-text {
  font-weight: 600;
  font-size: var(--font-size-sm);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.alarm-text.alarm-on {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.alarm-text.alarm-off {
  color: var(--color-text-muted);
  background: var(--color-bg);
}


/* --- Name Button (in gate tables) --- */
.name-button {
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
  width: 100%;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  transition: all var(--transition-fast);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
}

.name-button:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--color-accent);
}


/* --- Pagination --- */
.pagination {
  padding: var(--space-4) 0;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-3);
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.pagination a:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.pagination a.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}


/* --- Modals --- */
#nameModal,
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-surface);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  z-index: 1001;
  box-shadow: var(--shadow-xl);
  min-width: 320px;
  max-width: 90vw;
}

#nameModal h3,
.modal h3 {
  margin-bottom: var(--space-4);
  font-size: var(--font-size-lg);
}

#nameModal input,
.modal input {
  margin-bottom: var(--space-4);
}

#modalOverlay,
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
}


/* --- Messages & Alerts --- */
.msg,
.message {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: var(--font-size-sm);
  margin: var(--space-3) 0;
  text-align: center;
}

.msg-success,
.message-success {
  color: #166534;
  background: var(--color-success-bg);
  border: 1px solid #bbf7d0;
}

.msg-error,
.message-error {
  color: #991b1b;
  background: var(--color-danger-bg);
  border: 1px solid #fecaca;
}

.msg-warning {
  color: #92400e;
  background: var(--color-warning-bg);
  border: 1px solid #fde68a;
}

.flash-success {
  background: var(--color-success-bg);
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  text-align: center;
  font-weight: 500;
}


/* --- Tags / Badges --- */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.tag.critical {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: #fecaca;
}

.no-template {
  color: var(--color-text-muted);
  font-style: italic;
}

.no-action {
  display: inline-block;
  color: var(--color-text-muted);
  font-style: italic;
}


/* --- Diff Highlight (edit_vars) --- */
.diff {
  background: var(--color-warning-bg);
  border-left: 3px solid var(--color-warning);
}


/* --- VPN Loading --- */
#vpn-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--space-3);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* --- Login / Auth Pages --- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-primary-dark);
  background-size: cover;
  background-position: center;
  padding: var(--space-4);
}

.login-container,
.auth-form {
  background: var(--color-surface);
  padding: var(--space-8) var(--space-6);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.login-container img {
  max-width: 180px;
  margin-bottom: var(--space-6);
}

.login-container h2,
.auth-form h2 {
  margin-bottom: var(--space-4);
  font-size: var(--font-size-xl);
}

.login-container input,
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  margin-bottom: var(--space-3);
}

.login-container button,
.auth-form button[type="submit"] {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.reset-link {
  display: block;
  margin-top: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.reset-link:hover {
  color: var(--color-accent);
}


/* --- Language Switcher --- */
.language-switcher {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-sm);
  z-index: 10;
  display: flex;
  gap: var(--space-1);
}

.language-switcher a {
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  color: var(--color-text-secondary);
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.language-switcher a.active {
  color: white;
  background: var(--color-primary);
}

.language-switcher a:hover:not(.active) {
  background: var(--color-bg);
}


/* --- Tiles (home.php) --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
  padding: var(--space-4);
}

.tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
}

.tile:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}


/* --- Section / Card --- */
.section {
  margin: var(--space-4) 0;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}


/* --- Chart Pages --- */
.chart-container {
  position: relative;
  margin: var(--space-4) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chart-container canvas {
  cursor: grab;
}

.chart-container canvas:active {
  cursor: grabbing;
}


/* --- Checkbox Custom --- */
.checkbox-container {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
  margin-top: 2px;
}


/* --- Reconnect Overlay --- */
.reconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  color: white;
}


/* --- Utility Classes --- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.font-bold { font-weight: 600; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.p-4 { padding: var(--space-4); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none; }


/* ========================================================================
   RESPONSIVE DESIGN
   ======================================================================== */

@media (max-width: 768px) {
  :root {
    --sidebar-min-width: 100%;
    --top-bar-height: 50px;
  }

  body {
    font-size: var(--font-size-sm);
  }

  .top-bar {
    padding: 0 var(--space-3);
    font-size: var(--font-size-base);
  }

  .layout {
    flex-direction: column;
    height: calc(100vh - var(--top-bar-height));
  }

  .layout.expanded {
    height: 200vh;
  }

  .sidebar {
    position: absolute;
    width: 100%;
    height: 100%;
    max-height: 90vh;
    max-width: 100vw;
    transform: translateY(0);
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.hidden {
    transform: translateY(calc(-100vh - var(--top-bar-height)));
    box-shadow: none;
  }

  .sidebar-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .main {
    margin-left: 0 !important;
    width: 100%;
    transition: margin-top var(--transition-base);
    margin-top: calc(100vh - var(--top-bar-height));
    height: 95vh;
  }

  .main.active-top {
    margin-top: 0;
    height: 90vh;
  }

  .container {
    width: 100%;
    border-radius: 0;
    padding: var(--space-4);
    margin: 0;
    box-shadow: none;
  }

  /* Responsive table - card layout */
  .table-responsive table,
  .table-responsive thead,
  .table-responsive tbody,
  .table-responsive th,
  .table-responsive td,
  .table-responsive tr {
    display: block;
  }

  .table-responsive thead tr {
    display: none;
  }

  .table-responsive tbody tr {
    margin-bottom: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
  }

  .table-responsive td {
    text-align: right;
    padding-left: 50%;
    position: relative;
    border-bottom: 1px solid var(--color-border-light);
  }

  .table-responsive td::before {
    position: absolute;
    left: var(--space-3);
    top: var(--space-3);
    width: 45%;
    white-space: nowrap;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-align: left;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  /* Simple scrollable table for wide data */
  .table-scroll {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .filter-form,
  .filter-box {
    flex-direction: column;
    gap: var(--space-2);
  }

  .filter-form input,
  .filter-form select,
  .filter-box input,
  .filter-box select {
    min-width: unset;
  }

  .pagination {
    gap: 2px;
  }

  .pagination a {
    min-width: 32px;
    height: 32px;
    font-size: var(--font-size-xs);
    padding: 0 var(--space-2);
  }

  .filter-row th:nth-child(1),
  td:nth-child(1),
  th:nth-child(1) {
    display: none;
  }

  .tiles {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .login-container,
  .auth-form {
    padding: var(--space-6) var(--space-4);
    border-radius: var(--radius-lg);
    max-width: 100%;
  }

  .btn-sm {
    font-size: 11px;
    padding: 3px 6px;
  }
}

@media (max-width: 480px) {
  .sidebar-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .language-switcher {
    top: var(--space-2);
    right: var(--space-2);
    font-size: var(--font-size-xs);
  }
}


/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}


/* --- Print --- */
@media print {
  .top-bar,
  .sidebar,
  .sidebar-buttons,
  .pagination,
  .toggle-sidebar,
  .filter-row {
    display: none !important;
  }

  .main {
    margin: 0 !important;
  }

  body {
    background: white;
  }
}
