/* ============================================
   KS AQUA — AI Document Management System
   Premium Design System v2.0
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Brand Colors */
  --primary: #1a6fb5;
  --primary-hover: #2080cc;
  --dark-blue: #0c2d48;
  --light-blue: #4da8da;
  --accent: #38bdf8;

  /* Background */
  --bg-deep: #0a0e1a;
  --bg-surface: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --bg-elevated: rgba(30, 41, 59, 0.6);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #38bdf8;

  /* Security Zones */
  --zone-red: #ef4444;
  --zone-yellow: #eab308;
  --zone-green: #22c55e;
  --zone-white: #94a3b8;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-focus: #1a6fb5;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(26, 111, 181, 0.15);
  --shadow-glow-strong: 0 0 40px rgba(26, 111, 181, 0.25);

  /* Spacing */
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.3s;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Ambient background gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(26, 111, 181, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(77, 168, 218, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(12, 45, 72, 0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Agdasima', 'Roboto', sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

a {
  color: var(--light-blue);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
a:hover { color: var(--accent); }

img { max-width: 100%; display: block; }

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

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

/* ---------- Glass Card ---------- */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--duration) var(--ease);
}
.glass-card:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-glow);
}

/* ---------- App Layout ---------- */
#app {
  position: relative;
  z-index: 1;
}

/* ====== LOGIN PAGE ====== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  position: relative;
}

.login-container {
  width: 100%;
  max-width: 440px;
  position: relative;
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg), var(--shadow-glow-strong);
  position: relative;
  overflow: hidden;
}

/* Top gradient accent line */
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--light-blue), var(--accent));
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.login-logo img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 12px rgba(26, 111, 181, 0.3));
}

.login-logo h1 {
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--text-primary), var(--light-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.login-logo .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all var(--duration) var(--ease);
}

.form-input:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 111, 181, 0.15);
}

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

/* MFA Input */
.mfa-section {
  display: none;
  animation: slideDown 0.4s var(--ease);
}
.mfa-section.active { display: block; }

.mfa-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

.mfa-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: all var(--duration) var(--ease);
}
.mfa-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 111, 181, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--light-blue));
  color: white;
  box-shadow: 0 2px 8px rgba(26, 111, 181, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(26, 111, 181, 0.4);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1rem;
}

.btn-full { width: 100%; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

/* Loading spinner in button */
.btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}
.btn.loading .spinner { display: block; }
.btn.loading .btn-text { display: none; }

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  color: #fca5a5;
  font-size: 0.85rem;
  display: none;
  animation: shake 0.4s var(--ease);
}
.login-error.visible { display: block; }

/* ====== MAIN LAYOUT ====== */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100dvh;
}

/* ====== SIDEBAR ====== */
.sidebar {
  grid-area: sidebar;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 100;
  transition: transform var(--duration) var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(26, 111, 181, 0.3));
}

.sidebar-brand-text h2 {
  font-size: 1.1rem;
  color: var(--text-primary);
  line-height: 1.2;
}
.sidebar-brand-text span {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 16px 14px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(26, 111, 181, 0.15);
  color: var(--accent);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-item .nav-icon {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

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

.sidebar-footer a {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.sidebar-footer a:hover { color: var(--light-blue); }

.sidebar-footer .powered-by {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  margin: 8px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ====== HEADER ====== */
.header {
  grid-area: header;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  margin-left: var(--sidebar-width);
  height: var(--header-height);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--duration) var(--ease);
}
.hamburger:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.header-user:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--light-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
}

.user-info {
  display: flex;
  flex-direction: column;
}
.user-info .name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}
.user-info .role {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-logout {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all var(--duration) var(--ease);
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ====== MAIN CONTENT ====== */
.main-content {
  grid-area: main;
  padding: 24px;
  margin-left: var(--sidebar-width);
  overflow-y: auto;
  min-height: calc(100dvh - var(--header-height));
}

.page {
  display: none;
  animation: fadeIn 0.35s var(--ease);
}
.page.active { display: block; }

/* ====== DASHBOARD ====== */
.welcome-banner {
  background: linear-gradient(135deg, rgba(26, 111, 181, 0.15), rgba(77, 168, 218, 0.08));
  border: 1px solid rgba(26, 111, 181, 0.2);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(77, 168, 218, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.welcome-banner h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome-banner p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.stat-card .stat-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: rgba(26, 111, 181, 0.12);
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: 'Agdasima', sans-serif;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-full {
  grid-column: 1 / -1;
}

/* Status Cards */
.status-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.status-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.status-card-header h3 {
  font-size: 1.05rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge.idle {
  background: rgba(34, 197, 94, 0.12);
  color: var(--zone-green);
}
.status-badge.running {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
}
.status-badge.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--zone-red);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
}
.status-row:last-child { border-bottom: none; }

.status-row .label {
  color: var(--text-secondary);
}
.status-row .value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Zone Distribution */
.zone-bar-container {
  margin-top: 16px;
}

.zone-bar {
  height: 10px;
  border-radius: 5px;
  display: flex;
  overflow: hidden;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.zone-bar-segment {
  height: 100%;
  transition: width 0.6s var(--ease);
}

.zone-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.zone-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.zone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.zone-dot.red { background: var(--zone-red); }
.zone-dot.yellow { background: var(--zone-yellow); }
.zone-dot.green { background: var(--zone-green); }
.zone-dot.white { background: var(--zone-white); }

/* Recent Documents List */
.doc-list {
  list-style: none;
}

.doc-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  border-bottom: 1px solid var(--border-subtle);
}
.doc-list-item:last-child { border-bottom: none; }
.doc-list-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.doc-icon {
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(26, 111, 181, 0.1);
  flex-shrink: 0;
}

.doc-info {
  flex: 1;
  min-width: 0;
}
.doc-info .doc-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-info .doc-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Zone Badge */
.zone-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.zone-badge.red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--zone-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.zone-badge.yellow {
  background: rgba(234, 179, 8, 0.12);
  color: var(--zone-yellow);
  border: 1px solid rgba(234, 179, 8, 0.2);
}
.zone-badge.green {
  background: rgba(34, 197, 94, 0.12);
  color: var(--zone-green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.zone-badge.white {
  background: rgba(148, 163, 184, 0.12);
  color: var(--zone-white);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

/* ====== FILE BROWSER ====== */
.file-browser {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  height: calc(100dvh - var(--header-height) - 48px);
}

.folder-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  padding: 16px;
}

.folder-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.folder-panel-header h3 {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.folder-tree {
  list-style: none;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.folder-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.folder-item.active {
  background: rgba(26, 111, 181, 0.12);
  color: var(--accent);
}

.folder-item .folder-icon { font-size: 1rem; }
.folder-item .folder-zone {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}

/* File Panel */
.file-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.file-toolbar .toolbar-left {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.file-toolbar .toolbar-right {
  display: flex;
  gap: 6px;
}

.view-toggle {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.view-toggle button {
  padding: 8px 12px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all var(--duration) var(--ease);
}
.view-toggle button.active {
  background: rgba(26, 111, 181, 0.2);
  color: var(--accent);
}
.view-toggle button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.04);
}

/* File Table */
.file-table-container {
  flex: 1;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.file-table {
  width: 100%;
  border-collapse: collapse;
}

.file-table thead {
  position: sticky;
  top: 0;
  background: rgba(10, 14, 26, 0.95);
  z-index: 5;
}

.file-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.file-table td {
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.file-table tr {
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}
.file-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.file-table .file-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-weight: 500;
}

.file-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
  background: transparent;
}
.file-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.file-checkbox:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: white;
}

.ai-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
}
.ai-status.processed { color: var(--zone-green); }
.ai-status.pending { color: var(--zone-yellow); }
.ai-status.error { color: var(--zone-red); }

/* Grid View */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.file-grid-item {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.file-grid-item:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.file-grid-item .grid-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.file-grid-item .grid-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.file-grid-item .grid-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ====== SEARCH PAGE ====== */
.search-header {
  margin-bottom: 24px;
}

.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all var(--duration) var(--ease);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 111, 181, 0.15), var(--shadow-glow);
}

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-select {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.filter-select:focus {
  border-color: var(--primary);
}

.filter-input {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all var(--duration) var(--ease);
  max-width: 160px;
}
.filter-input:focus { border-color: var(--primary); }

.search-results {
  list-style: none;
}

.search-result-item {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.search-result-item:hover {
  border-color: var(--border-light);
  background: var(--bg-glass-hover);
  box-shadow: var(--shadow-glow);
}

.search-result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.search-result-header .result-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.search-result-header .result-folder {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.search-result-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.search-result-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 500;
  background: rgba(26, 111, 181, 0.1);
  color: var(--light-blue);
  border: 1px solid rgba(26, 111, 181, 0.2);
}

.search-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.search-empty .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ====== DOCUMENT DETAIL MODAL ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s var(--ease);
}
.modal-overlay.active {
  display: flex;
}

.modal {
  background: rgba(15, 20, 35, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 720px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), var(--shadow-glow-strong);
  animation: modalIn 0.3s var(--ease);
  overflow: hidden;
}

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

.modal-header h2 {
  font-size: 1.2rem;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 12px;
}

.modal-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-secondary);
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  flex-shrink: 0;
}

.modal-tab {
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: all var(--duration) var(--ease);
}

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

.modal-tab.active {
  color: var(--accent);
}
.modal-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s var(--ease);
}
.tab-content.active { display: block; }

/* Summary Tab */
.confidence-score {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.confidence-score.high {
  background: rgba(34, 197, 94, 0.12);
  color: var(--zone-green);
}
.confidence-score.medium {
  background: rgba(234, 179, 8, 0.12);
  color: var(--zone-yellow);
}
.confidence-score.low {
  background: rgba(239, 68, 68, 0.12);
  color: var(--zone-red);
}

.summary-text {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* Keywords Tab */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}

.keyword-cloud .keyword-tag {
  padding: 6px 14px;
  font-size: 0.85rem;
}

/* Versions Tab */
.version-timeline {
  position: relative;
  padding-left: 24px;
}

.version-timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border-subtle);
}

.version-item {
  position: relative;
  padding: 12px 0 12px 16px;
}

.version-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-deep);
}

.version-item:first-child::before {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.version-item .version-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.version-item .version-desc {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* Activity Tab */
.activity-list {
  list-style: none;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(26, 111, 181, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.activity-info {
  flex: 1;
}
.activity-info .activity-text {
  font-size: 0.88rem;
  color: var(--text-primary);
}
.activity-info .activity-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ====== AGENT CONTROL ====== */
.agent-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.agent-status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  position: relative;
}

.pulse-dot.idle {
  background: var(--zone-green);
}

.pulse-dot.running {
  background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

.pulse-dot.running::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulseRing 1.5s ease-out infinite;
}

.agent-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.agent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* Agent Run Log */
.run-log-table {
  width: 100%;
  border-collapse: collapse;
}

.run-log-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.run-log-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.run-log-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* LLM Provider */
.provider-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.provider-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  text-align: center;
}
.provider-card:hover {
  border-color: var(--border-light);
}
.provider-card.active {
  border-color: var(--primary);
  background: rgba(26, 111, 181, 0.1);
}
.provider-card .provider-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 8px;
  font-size: 0.9rem;
}
.provider-card .provider-icon {
  font-size: 1.8rem;
}

/* ====== BACKUP PAGE ====== */
.backup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.snapshot-list {
  list-style: none;
}

.snapshot-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
}
.snapshot-item:last-child { border-bottom: none; }

.snapshot-item .snap-icon {
  font-size: 1.1rem;
  color: var(--light-blue);
}

.snapshot-item .snap-date {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}

.snapshot-item .snap-size {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Disk Usage Bar */
.disk-usage-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin: 8px 0;
}

.disk-usage-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--light-blue));
  transition: width 0.6s var(--ease);
}

.disk-usage-fill.warning {
  background: linear-gradient(90deg, var(--zone-yellow), #f59e0b);
}

.disk-usage-fill.critical {
  background: linear-gradient(90deg, var(--zone-red), #dc2626);
}

/* ====== SETTINGS PAGE ====== */
.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-section {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.settings-section h3 {
  font-size: 1.05rem;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-row:last-child { border-bottom: none; }

.settings-row label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.settings-row .form-input {
  max-width: 300px;
}

.user-list-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.user-list-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}
.user-list-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.system-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.info-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
}
.info-card .info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.info-card .info-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ====== TOAST / NOTIFICATIONS ====== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: rgba(15, 20, 35, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s var(--ease);
  min-width: 280px;
  max-width: 400px;
}

.toast.success { border-left: 3px solid var(--zone-green); }
.toast.error { border-left: 3px solid var(--zone-red); }
.toast.info { border-left: 3px solid var(--light-blue); }

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

.toast-close {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
}

/* ====== SKELETON LOADING ====== */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 60%; }

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-md);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

/* ====== EMPTY STATES ====== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto;
}

/* ====== ANIMATIONS ====== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ====== RESPONSIVE ====== */
/* Tablet */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .agent-grid {
    grid-template-columns: 1fr;
  }
  .file-browser {
    grid-template-columns: 220px 1fr;
  }
}

/* Mobile landscape */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
  }
  .sidebar-overlay.active { display: block; }

  .hamburger {
    display: flex;
  }

  .header {
    margin-left: 0;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  .file-browser {
    grid-template-columns: 1fr;
    height: auto;
  }

  .folder-panel {
    max-height: 200px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card .stat-value {
    font-size: 1.4rem;
  }

  .search-bar {
    flex-direction: column;
  }

  .user-info {
    display: none;
  }

  .modal {
    max-width: 100%;
    max-height: 90dvh;
    border-radius: var(--radius-lg);
  }

  .welcome-banner {
    padding: 20px;
  }

  .welcome-banner h2 {
    font-size: 1.3rem;
  }

  .backup-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile portrait */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .file-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .file-toolbar .toolbar-left,
  .file-toolbar .toolbar-right {
    justify-content: stretch;
  }

  .file-toolbar .toolbar-left .btn,
  .file-toolbar .toolbar-right .btn {
    flex: 1;
  }

  .agent-controls {
    flex-direction: column;
  }

  .agent-controls .btn {
    width: 100%;
  }

  .mfa-digit {
    width: 40px;
    height: 48px;
    font-size: 1.2rem;
  }

  .login-card {
    padding: 32px 24px;
  }

  .login-logo h1 {
    font-size: 1.5rem;
  }

  .search-filters {
    flex-direction: column;
  }

  .filter-select,
  .filter-input {
    max-width: 100%;
    width: 100%;
  }

  .modal-tabs {
    overflow-x: auto;
    padding: 0 16px;
    gap: 0;
  }

  .modal-tab {
    white-space: nowrap;
    padding: 10px 12px;
    font-size: 0.8rem;
  }
}

/* ====== BOTTOM NAV (Mobile alt) ====== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  padding: 6px 0;
  padding-bottom: env(safe-area-inset-bottom, 6px);
}

@media (max-width: 768px) {
  .bottom-nav { display: flex; }
  .main-content {
    padding-bottom: 80px;
  }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
  transition: color var(--duration) var(--ease);
}
.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--accent);
}
.bottom-nav-item .bnav-icon {
  font-size: 1.2rem;
}

/* ====== PRINT ====== */
@media print {
  .sidebar,
  .header,
  .bottom-nav,
  .toast-container {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
  }
  body {
    background: white;
    color: black;
  }
}
