/* ============================================================
   Mission Control — Unified Stylesheet
   GitHub-dark inspired · Mobile-first · Accessible
   ============================================================ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-surface-hover: #1c2128;
  --bg-overlay: #21262d;
  --bg-input: #0d1117;

  /* Borders */
  --border-default: #30363d;
  --border-muted: #21262d;

  /* Text */
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;

  /* Accents */
  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-purple: #a371f7;
  --accent-orange: #d29922;
  --accent-red: #f85149;
  --accent-cyan: #39c5cf;

  /* Sizing */
  --sidebar-width: 260px;
  --header-height: 56px;
  --bottom-nav-height: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* 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 24px rgba(0, 0, 0, 0.5);

  /* Spacing scale */
  --sp-4: 4px;
  --sp-8: 8px;
  --sp-12: 12px;
  --sp-16: 16px;
  --sp-24: 24px;
  --sp-32: 32px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --text-xs: 0.6875rem;   /* 11px */
  --text-sm: 0.75rem;     /* 12px */
  --text-base: 0.875rem;  /* 14px */
  --text-md: 0.9375rem;   /* 15px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */

  /* Transition */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Layout: App Shell ────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--sp-24);
  padding-bottom: calc(var(--sp-24) + var(--bottom-nav-height) + 8px);
  transition: margin-left var(--transition-slow);
}

@media (min-width: 768px) {
  .app-main {
    margin-left: var(--sidebar-width);
    padding-bottom: var(--sp-24);
  }
}

@media (min-width: 1024px) {
  .app-main {
    margin-left: var(--sidebar-width);
  }
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-base);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform var(--transition-slow);
  overflow: hidden;
}

.sidebar.open {
  transform: translateX(0);
}

@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
  }
}

/* Sidebar Header */
.sidebar-header {
  padding: var(--sp-16);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
}

.brand-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}

.brand-info h1 {
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.2;
}

.brand-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--text-muted);
  animation: none;
}

.status-dot.working {
  background: var(--accent-green);
}

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

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-12) var(--sp-8);
}

.nav-section {
  margin-bottom: var(--sp-16);
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: var(--sp-8) var(--sp-12);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: 10px var(--sp-12);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: var(--text-md);
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  padding: 2px var(--sp-8);
  background: var(--bg-overlay);
  border-radius: 10px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border-default);
  padding: var(--sp-12);
  flex-shrink: 0;
}

.sidebar-footer .nav-item.logout-btn:hover {
  color: var(--accent-red);
  background: rgba(248, 81, 73, 0.1);
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 199;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Bottom Navigation (mobile) ───────────────────────────── */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  z-index: 200;
  align-items: stretch;
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  position: relative;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
  font-size: 1.125rem;
  line-height: 1;
}

.bottom-nav-item.active {
  color: var(--accent-blue);
}

.bottom-nav-item:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent-blue);
  border-radius: 0 0 2px 2px;
}

/* More Sheet */
.more-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 299;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.more-sheet-overlay.active {
  display: block;
  opacity: 1;
}

.more-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 300;
  transform: translateY(100%);
  transition: transform var(--transition-slow);
  padding: var(--sp-8) 0 var(--sp-16);
  max-height: 70vh;
  overflow-y: auto;
}

.more-sheet.open {
  transform: translateY(0);
}

.more-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-default);
  border-radius: 2px;
  margin: var(--sp-8) auto var(--sp-16);
}

.more-sheet-item {
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  padding: var(--sp-16) var(--sp-24);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-md);
  transition: background var(--transition-fast);
}

.more-sheet-item:hover,
.more-sheet-item:active {
  background: var(--bg-surface-hover);
  text-decoration: none;
}

.more-sheet-item i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.more-sheet-item.danger {
  color: var(--accent-red);
}

.more-sheet-divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--sp-8) var(--sp-24);
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-24);
  gap: var(--sp-16);
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.2;
}

.page-header p {
  color: var(--text-secondary);
  font-size: var(--text-base);
  margin-top: var(--sp-4);
}

@media (max-width: 767px) {
  .page-header {
    flex-direction: column;
  }
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--border-muted);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-12) var(--sp-16);
  border-bottom: 1px solid var(--border-default);
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: var(--text-base);
  font-weight: 600;
}

.card-title i {
  color: var(--accent-purple);
}

.card-body {
  padding: var(--sp-16);
}

.card-body-flush {
  padding: 0;
}

.card-action {
  font-size: var(--text-sm);
  color: var(--accent-blue);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

.card-action:hover {
  text-decoration: underline;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-12);
  margin-bottom: var(--sp-24);
}

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

@media (min-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--sp-16);
}

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

.stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.stat-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

.stat-icon.green  { color: var(--accent-green); }
.stat-icon.blue   { color: var(--accent-blue); }
.stat-icon.purple { color: var(--accent-purple); }
.stat-icon.orange { color: var(--accent-orange); }
.stat-icon.red    { color: var(--accent-red); }
.stat-icon.cyan   { color: var(--accent-cyan); }

.stat-value {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--sp-4);
}

.stat-value.online  { color: var(--accent-green); }
.stat-value.warning { color: var(--accent-orange); }
.stat-value.error   { color: var(--accent-red); }

.stat-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.stat-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  margin-top: var(--sp-8);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.stat-meta-badge {
  padding: 2px 6px;
  background: var(--bg-overlay);
  border-radius: 4px;
  font-size: var(--text-xs);
}

.stat-meta-badge.active {
  background: rgba(63, 185, 80, 0.15);
  color: var(--accent-green);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  padding: 10px 18px;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--accent-green);
  color: #fff;
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--bg-overlay);
  border-color: var(--border-default);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: var(--text-md);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}
.btn-icon:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--sp-16);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-8);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--sp-12) var(--sp-16);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

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

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-blue   { background: rgba(88, 166, 255, 0.15); color: var(--accent-blue); }
.badge-green  { background: rgba(63, 185, 80, 0.15);  color: var(--accent-green); }
.badge-purple { background: rgba(163, 113, 247, 0.15); color: var(--accent-purple); }
.badge-orange { background: rgba(210, 153, 34, 0.15);  color: var(--accent-orange); }
.badge-red    { background: rgba(248, 81, 73, 0.15);   color: var(--accent-red); }
.badge-cyan   { background: rgba(57, 197, 207, 0.15);  color: var(--accent-cyan); }
.badge-muted  { background: var(--bg-overlay); color: var(--text-muted); }

.priority-dot {
  font-size: 0.6rem;
}
.priority-high   { color: var(--accent-red); }
.priority-medium { color: var(--accent-orange); }
.priority-low    { color: var(--accent-green); }

/* ── Filter Tabs ──────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: var(--sp-8);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: var(--sp-4);
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  padding: var(--sp-8) var(--sp-16);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.filter-tab:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.filter-tab .count {
  margin-left: var(--sp-4);
  opacity: 0.7;
}

/* ── Task Items ───────────────────────────────────────────── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.task-item {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-16);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
  min-height: 48px;
}

.task-item:hover {
  border-color: var(--accent-blue);
}

.task-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-default);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  padding: 0;
  font-size: 0.6rem;
  color: transparent;
}

.task-checkbox:hover {
  border-color: var(--accent-blue);
}

.task-checkbox.todo {
  border-color: var(--accent-orange);
}

.task-checkbox.in-progress {
  border-color: var(--accent-blue);
  background: rgba(88, 166, 255, 0.2);
  color: var(--accent-blue);
}

.task-checkbox.done {
  border-color: var(--accent-green);
  background: var(--accent-green);
  color: #fff;
}

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

.task-name {
  font-size: var(--text-md);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-name.done {
  text-decoration: line-through;
  opacity: 0.6;
}

.task-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: var(--sp-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-actions {
  display: flex;
  gap: var(--sp-4);
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.task-item:hover .task-actions {
  opacity: 1;
}

/* Always show on touch devices */
@media (hover: none) {
  .task-actions {
    opacity: 1;
  }
}

/* ── Activity Items ───────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: var(--sp-12);
  padding: var(--sp-12);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.activity-item:hover {
  background: var(--bg-surface-hover);
}

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--text-sm);
  color: var(--accent-blue);
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: 0.8125rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Quick Add Bar ────────────────────────────────────────── */
.quick-add {
  display: flex;
  gap: var(--sp-12);
  padding: var(--sp-16);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-16);
}

@media (max-width: 599px) {
  .quick-add {
    flex-direction: column;
  }
}

.quick-add .form-input {
  flex: 1;
}

/* ── Context Bar ──────────────────────────────────────────── */
.context-bar {
  margin-top: var(--sp-12);
  padding-top: var(--sp-12);
  border-top: 1px solid var(--border-default);
}

.context-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.context-bar-header span {
  font-size: var(--text-sm);
}

.context-bar-header .label { color: var(--text-secondary); }
.context-bar-header .value { color: var(--text-primary); font-weight: 500; }

.progress-track {
  height: 6px;
  background: var(--bg-overlay);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-green);
  transition: width var(--transition-slow), background-color var(--transition-slow);
}

.progress-fill.warning { background: var(--accent-orange); }
.progress-fill.danger  { background: var(--accent-red); }

.context-bar-footer {
  display: flex;
  justify-content: space-between;
  margin-top: var(--sp-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.context-bar-model {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-4);
  text-align: center;
}

/* ── Content Grid ─────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-24);
}

@media (min-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr 300px;
  }
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table th,
.table td {
  padding: var(--sp-12) var(--sp-16);
  text-align: left;
  border-bottom: 1px solid var(--border-default);
}

.table th {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
}

.table tr:hover td {
  background: var(--bg-surface-hover);
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
  padding: var(--sp-16);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-normal);
}

.modal-backdrop.active .modal {
  transform: scale(1) translateY(0);
}

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

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  transition: all var(--transition-fast);
}

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

.modal-body {
  padding: var(--sp-24);
}

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

@media (max-width: 599px) {
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 100vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    min-height: 50vh;
  }
}

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--sp-16);
  right: var(--sp-16);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  pointer-events: none;
  max-width: 380px;
}

@media (max-width: 599px) {
  .toast-container {
    top: var(--sp-12);
    left: var(--sp-12);
    right: var(--sp-12);
    max-width: 100%;
    align-items: center;
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-16);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: var(--text-base);
  color: var(--text-primary);
  pointer-events: auto;
  animation: toast-in var(--transition-normal) ease;
  min-width: 250px;
}

.toast.removing {
  animation: toast-out var(--transition-normal) ease forwards;
}

.toast-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.success .toast-icon { color: var(--accent-green); }

.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.error .toast-icon   { color: var(--accent-red); }

.toast.info    { border-left: 3px solid var(--accent-blue); }
.toast.info .toast-icon    { color: var(--accent-blue); }

.toast.warning { border-left: 3px solid var(--accent-orange); }
.toast.warning .toast-icon { color: var(--accent-orange); }

.toast-message {
  flex: 1;
  min-width: 0;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

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

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ── Loading Skeletons ────────────────────────────────────── */
.skeleton {
  background: var(--bg-overlay);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

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

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

.skeleton-line.short  { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long   { width: 100%; }

.skeleton-block {
  height: 60px;
  margin-bottom: var(--sp-12);
}

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

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

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2rem;
  margin-bottom: var(--sp-12);
  display: block;
  opacity: 0.5;
}

.empty-state p {
  font-size: var(--text-base);
  margin-top: var(--sp-8);
}

/* ── Device / Agent Card ──────────────────────────────────── */
.device-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--sp-16);
}

.device-header {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
}

.device-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-overlay);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  color: var(--accent-green);
  flex-shrink: 0;
}

.device-name {
  font-size: var(--text-base);
  font-weight: 600;
}

.device-status {
  font-size: var(--text-sm);
  color: var(--accent-green);
}

/* ── Login Page ───────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-24);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--sp-24);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
}

.login-card h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-bottom: var(--sp-8);
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: var(--text-base);
  margin-bottom: var(--sp-32);
}

.login-footer {
  margin-top: var(--sp-24);
  padding-top: 20px;
  border-top: 1px solid var(--border-muted);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.error-message {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  padding: var(--sp-12);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: var(--sp-16);
  display: none;
}

.error-message.show {
  display: block;
}

/* ── Utility Classes ──────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--accent-green); }
.text-danger  { color: var(--accent-red); }
.text-warning { color: var(--accent-orange); }

.font-mono { font-family: var(--font-mono); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4  { gap: var(--sp-4); }
.gap-8  { gap: var(--sp-8); }
.gap-12 { gap: var(--sp-12); }
.gap-16 { gap: var(--sp-16); }
.gap-24 { gap: var(--sp-24); }

.mt-8  { margin-top: var(--sp-8); }
.mt-12 { margin-top: var(--sp-12); }
.mt-16 { margin-top: var(--sp-16); }
.mt-24 { margin-top: var(--sp-24); }
.mb-8  { margin-bottom: var(--sp-8); }
.mb-12 { margin-bottom: var(--sp-12); }
.mb-16 { margin-bottom: var(--sp-16); }
.mb-24 { margin-bottom: var(--sp-24); }

.p-8  { padding: var(--sp-8); }
.p-12 { padding: var(--sp-12); }
.p-16 { padding: var(--sp-16); }
.p-24 { padding: var(--sp-24); }

.w-full { width: 100%; }
.flex-1 { flex: 1; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hidden { display: none !important; }

.overflow-y-auto {
  overflow-y: auto;
}

/* ── Scrollable Section ───────────────────────────────────── */
.scroll-section {
  max-height: 450px;
  overflow-y: auto;
}

@media (max-width: 767px) {
  .scroll-section {
    max-height: none;
  }
}

/* ── Section Title (right panel, etc.) ────────────────────── */
.section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: var(--sp-12);
}

/* ── Touch enhancements ───────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .nav-item,
  .task-item,
  .activity-item,
  .bottom-nav-item {
    min-height: 48px;
  }

  .nav-item:hover,
  .task-item:hover,
  .activity-item:hover {
    background: transparent;
  }

  .nav-item:active,
  .task-item:active,
  .activity-item:active {
    background: var(--bg-surface-hover);
  }

  button:active {
    transform: scale(0.98);
  }
}

/* ── Accessibility ────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Forced Colors (High Contrast) ────────────────────────── */
@media (forced-colors: active) {
  .btn {
    border: 1px solid ButtonText;
  }

  .badge {
    border: 1px solid;
  }

  .card {
    border: 1px solid;
  }

  .task-checkbox {
    border: 2px solid ButtonText;
  }

  .progress-fill {
    background: Highlight;
  }
}

/* ── Task Plan (collapsible) ───────────────────────────────── */
.task-plan {
  margin-top: var(--sp-8);
  border-left: 3px solid var(--accent-purple);
  background: rgba(163, 113, 247, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  overflow: hidden;
}

.task-plan-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  padding: var(--sp-8) var(--sp-12);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent-purple);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.task-plan-toggle:hover {
  background: rgba(163, 113, 247, 0.08);
}

.task-plan-toggle i {
  font-size: var(--text-xs);
  transition: transform var(--transition-fast);
}

.task-plan-toggle.expanded i {
  transform: rotate(90deg);
}

.task-plan-content {
  padding: 0 var(--sp-12) var(--sp-12);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
  display: none;
}

.task-plan-content.show {
  display: block;
}

/* ── Comment Timeline ─────────────────────────────────────── */
.comment-timeline {
  position: relative;
  padding: var(--sp-8) 0;
}

.comment-timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-default);
}

.comment-item {
  position: relative;
  padding-left: 32px;
  margin-bottom: var(--sp-16);
}

.comment-item:last-child {
  margin-bottom: 0;
}

.comment-dot {
  position: absolute;
  left: 5px;
  top: 3px;
  width: 14px;
  height: 14px;
  background: var(--bg-surface);
  border: 2px solid var(--accent-blue);
  border-radius: 50%;
  z-index: 1;
}

.comment-text {
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: 1.5;
  word-wrap: break-word;
}

.comment-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.comment-input {
  display: flex;
  gap: var(--sp-8);
  margin-top: var(--sp-16);
  padding-top: var(--sp-16);
  border-top: 1px solid var(--border-default);
}

.comment-input .form-input {
  flex: 1;
}

/* ── Stalled Task Banner ──────────────────────────────────── */
.stalled-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-16);
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-16);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: var(--text-base);
  color: var(--accent-orange);
  font-weight: 500;
}

.stalled-banner:hover {
  background: rgba(210, 153, 34, 0.15);
}

.stalled-banner i {
  font-size: var(--text-lg);
}

.stalled-banner .stalled-text {
  flex: 1;
}

.stalled-banner .stalled-action {
  font-size: var(--text-sm);
  opacity: 0.7;
}

/* ── Task Detail Modal Extras ─────────────────────────────── */
.task-detail-section {
  margin-bottom: var(--sp-16);
}

.task-detail-section:last-child {
  margin-bottom: 0;
}

.task-detail-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: var(--sp-8);
}

.task-detail-meta {
  display: flex;
  gap: var(--sp-8);
  flex-wrap: wrap;
  margin-bottom: var(--sp-16);
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar,
  .bottom-nav,
  .sidebar-overlay,
  .more-sheet-overlay,
  .more-sheet,
  .toast-container,
  .modal-backdrop {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .app-main {
    margin-left: 0;
    padding: 0;
  }

  .card {
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
