/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-base: #0a0a0f;
  --bg-surface: #14141f;
  --bg-elevated: #1c1c2a;
  --bg-hover: #22223a;

  /* Borders */
  --border-subtle: #2a2a3e;
  --border-default: #3a3a52;
  --border-focus: #6366f1;

  /* Accent */
  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-secondary: #4f46e5;

  /* Status */
  --status-online: #22c55e;
  --status-offline: #64748b;
  --status-error: #ef4444;

  /* Battery */
  --battery-full: #22c55e;
  --battery-medium: #eab308;
  --battery-low: #ef4444;

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0a0a0f;

  /* Semantic */
  --destructive: #dc2626;
  --destructive-hover: #ef4444;
  --success: #22c55e;
  --warning: #eab308;

  /* Typography */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* 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;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.6);
  --shadow-elevated: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.4);
  --shadow-modal: 0 25px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
}

::selection {
  background: var(--accent-primary);
  color: var(--text-primary);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
}

.login-card.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.login-icon {
  color: var(--accent-primary);
  margin-bottom: var(--space-2);
}

.login-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  text-align: center;
}

.login-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
  margin-top: calc(var(--space-1) * -1);
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.login-error {
  font-size: var(--text-sm);
  color: var(--status-error);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  display: none;
}

.login-error.visible {
  display: block;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.btn-destructive {
  background: var(--destructive);
  color: #fff;
  font-weight: var(--font-semibold);
}

.btn-destructive:hover:not(:disabled) {
  background: var(--destructive-hover);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.btn-icon {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
}

.btn .spinner {
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   FORM INPUTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

.form-input.error {
  border-color: var(--status-error);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--status-error);
}

.form-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  width: 100%;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: background var(--transition-base);
  flex-shrink: 0;
}

.toggle.on {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition-base);
}

.toggle.on .toggle-knob {
  transform: translateX(20px);
}

.toggle-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  text-decoration: none;
}

.navbar-brand i {
  color: var(--accent-primary);
}

.navbar-user {
  position: relative;
}

.navbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-secondary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.navbar-avatar:hover {
  background: var(--accent-primary);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  min-width: 160px;
  overflow: hidden;
  display: none;
  z-index: 200;
}

.user-dropdown.open {
  display: block;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  width: 100%;
  text-align: left;
}

.user-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.user-dropdown-item.danger {
  color: var(--status-error);
}

.user-dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
  padding-top: 64px;
  min-height: 100vh;
}

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-6);
  background: var(--bg-surface);
  position: sticky;
  top: 64px;
  z-index: 50;
}

.tab {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color var(--transition-base), border-color var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}

/* ============================================================
   LOCK CARDS
   ============================================================ */
.lock-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .lock-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.lock-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
  cursor: default;
}

.lock-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-elevated);
  transform: scale(1.01);
}

.lock-card.offline {
  opacity: 0.7;
}

.lock-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: var(--space-1);
}

.lock-info {
  flex: 1;
  min-width: 0;
}

.lock-name {
  font-size: var(--text-lg);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.lock-meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.lock-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ============================================================
   STATUS PILL
   ============================================================ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

.status-pill.online {
  background: rgba(34, 197, 94, 0.15);
  color: var(--status-online);
}

.status-pill.offline {
  background: rgba(100, 116, 139, 0.15);
  color: var(--status-offline);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================================
   BATTERY METER
   ============================================================ */
.battery-meter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.battery-track {
  width: 80px;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.battery-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.battery-fill.full { background: var(--battery-full); }
.battery-fill.medium { background: var(--battery-medium); }
.battery-fill.low { background: var(--battery-low); }

.battery-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ============================================================
   GROUPS PAGE
   ============================================================ */
.groups-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .groups-layout {
    grid-template-columns: 2fr 3fr;
  }
}

.groups-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.group-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.group-card:hover {
  border-color: var(--border-default);
  background: var(--bg-hover);
}

.group-card.selected {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
}

.group-card-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.group-card-icon {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.group-card-name {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-card-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.group-detail {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.group-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.group-detail-name {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.group-locks-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.group-lock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.group-lock-item-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.group-lock-item-remove {
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  display: flex;
  align-items: center;
}

.group-lock-item-remove:hover {
  color: var(--status-error);
  background: rgba(239, 68, 68, 0.1);
}

.group-detail-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================
   ACCESS CODES PAGE
   ============================================================ */
.codes-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.codes-controls .form-select {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}

.codes-controls .btn {
  flex-shrink: 0;
}

/* Codes table */
.codes-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.codes-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.codes-table thead {
  border-bottom: 1px solid var(--border-subtle);
}

.codes-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-surface);
  white-space: nowrap;
}

.codes-table th:first-child {
  width: 40px;
  text-align: center;
}

.codes-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.codes-table tbody tr {
  transition: background var(--transition-fast);
}

.codes-table tbody tr:hover {
  background: var(--bg-hover);
}

.codes-table tbody tr:last-child td {
  border-bottom: none;
}

.codes-table tbody tr.selected {
  background: rgba(99, 102, 241, 0.06);
}

.code-value-cell {
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.code-value-masked {
  color: var(--text-muted);
  letter-spacing: 0.1em;
  cursor: pointer;
}

.code-toggle-btn {
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  padding: 0;
}

.code-toggle-btn:hover {
  color: var(--text-secondary);
}

.code-schedule {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.actions-cell {
  text-align: right;
  white-space: nowrap;
}

.actions-cell .btn-icon {
  width: 32px;
  height: 32px;
}

.three-dot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  background: none;
  border: none;
  position: relative;
}

.three-dot-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.three-dot-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  min-width: 160px;
  overflow: hidden;
  z-index: 100;
  display: none;
}

.three-dot-menu.open {
  display: block;
}

.three-dot-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
}

.three-dot-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.three-dot-menu-item.danger {
  color: var(--status-error);
}

.three-dot-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Bulk action bar */
.bulk-bar {
  display: none;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.bulk-bar.visible {
  display: flex;
}

.bulk-bar-count {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  flex: 1;
}

.bulk-bar-actions {
  display: flex;
  gap: var(--space-2);
}

/* ============================================================
   CHECKBOX
   ============================================================ */
.checkbox-cell {
  text-align: center;
}

.checkbox {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  position: relative;
}

.checkbox:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox:checked::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

.checkbox:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  padding: var(--space-8);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.modal-close {
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* Slide-in from right */
.slide-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
}

.slide-modal-backdrop.open {
  display: block;
}

.slide-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  z-index: 301;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
}

.slide-modal.open {
  transform: translateX(0);
}

.slide-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.slide-modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.slide-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.slide-modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  font-size: var(--text-sm);
  pointer-events: all;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn var(--transition-slow) ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--status-error); }
.toast.warning { border-left: 3px solid var(--warning); }

.toast-icon {
  flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--status-error); }
.toast.warning .toast-icon { color: var(--warning); }

.toast-message {
  color: var(--text-primary);
  flex: 1;
}

.toast-close {
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-secondary);
}

.toast.toast-out {
  animation: toastOut var(--transition-base) ease forwards;
}

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

@keyframes toastOut {
  to { opacity: 0; transform: translateX(100%); }
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

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

.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-3);
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }

.skeleton-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 1fr 1fr 40px;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
}

.skeleton-row:last-child {
  border-bottom: none;
}

.skeleton-cell {
  height: 14px;
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  gap: var(--space-4);
}

.empty-state-icon {
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 320px;
}

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.confirm-modal .modal {
  max-width: 400px;
}

.confirm-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* ============================================================
   CODE FORM (in slide modal)
   ============================================================ */
.code-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.code-input-wrapper {
  position: relative;
}

.code-input-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
}

.code-input-toggle:hover {
  color: var(--text-secondary);
}

.datetime-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.datetime-row.hidden {
  display: none;
}

/* ============================================================
   LOCK CHECKBOX LIST (for groups)
   ============================================================ */
.lock-check-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.lock-check-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.lock-check-item:hover {
  background: var(--bg-hover);
}

.lock-check-item input[type="checkbox"] {
  cursor: pointer;
}

/* ============================================================
   GROUP NAME EDIT
   ============================================================ */
.group-name-edit {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.group-name-input {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  background: var(--bg-elevated);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-3);
  width: 200px;
  outline: none;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-error { color: var(--status-error); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
