/* ────────────────────────────────────────────────────────────────────────────
   Proxy Dashboard — Apple/iOS-inspired theme
   Soft dark mode · frosted glass · SF Pro typography · friendly + spacious
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces — softer dark tones inspired by macOS Big Sur dark mode */
  --bg-base:        #1c1c1e;        /* macOS-style dark bg */
  --bg-secondary:   #2c2c2e;        /* slightly lighter cards */
  --bg-tertiary:    #3a3a3c;        /* hover state */
  --bg-elevated:    #2c2c2e;        /* main card */
  --bg-glass:       rgba(44, 44, 46, 0.72);
  --bg-glass-thick: rgba(44, 44, 46, 0.85);

  /* Borders — almost invisible, just hints */
  --separator:      rgba(255, 255, 255, 0.08);
  --separator-bold: rgba(255, 255, 255, 0.14);
  --hairline:       rgba(255, 255, 255, 0.05);

  /* Text — Apple's exact dark mode opacities */
  --text-primary:    rgba(255, 255, 255, 0.92);
  --text-secondary:  rgba(235, 235, 245, 0.6);
  --text-tertiary:   rgba(235, 235, 245, 0.4);
  --text-quaternary: rgba(235, 235, 245, 0.25);

  /* Apple's signature system colors (dark mode variants) */
  --blue:        #0a84ff;
  --blue-hover:  #409cff;
  --blue-soft:   rgba(10, 132, 255, 0.15);
  --blue-glow:   rgba(10, 132, 255, 0.4);
  --blue-text:   #64b5ff;

  --green:       #30d158;
  --green-soft:  rgba(48, 209, 88, 0.15);
  --yellow:      #ffd60a;
  --yellow-soft: rgba(255, 214, 10, 0.15);
  --orange:      #ff9f0a;
  --red:         #ff453a;
  --red-soft:    rgba(255, 69, 58, 0.15);
  --purple:      #bf5af2;
  --pink:        #ff375f;
  --teal:        #64d2ff;
  --indigo:      #5e5ce6;

  /* Radii — Apple loves rounded corners */
  --r-xs:  6px;
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  24px;

  /* Shadows — soft, diffused, like real shadows from soft light */
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg:  0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-xl:  0 24px 60px rgba(0, 0, 0, 0.6);
  --ring:       0 0 0 4px var(--blue-glow);

  /* Easing — Apple's signature easing */
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 200ms var(--ease);
  --transition-slow: 350ms var(--ease-out);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.003em;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

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

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

/* iOS-style scrollbar — minimal, only on hover */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  transition: background var(--transition);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

code {
  background: var(--bg-tertiary);
  border-radius: var(--r-xs);
  padding: 2px 8px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--blue-text);
  font-weight: 500;
}

.muted { color: var(--text-secondary); }
.small { font-size: 13px; }

/* ────────────────────────────────────────────────────────────────────────────
   Login / signup — like a Sign in with Apple modal
   ──────────────────────────────────────────────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(circle 800px at 50% -10%, rgba(10, 132, 255, 0.12), transparent),
    radial-gradient(circle 600px at 90% 110%, rgba(94, 92, 230, 0.08), transparent),
    var(--bg-base);
}
.login-card {
  background: var(--bg-glass-thick);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--separator);
  border-radius: var(--r-xl);
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-xl);
}
.login-card .logo-large {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  margin: 0 auto 22px;
  box-shadow: 0 12px 28px var(--blue-glow), 0 1px 2px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.login-card .muted { margin: 0 0 28px; font-size: 14px; }
.login-card .error {
  background: var(--red-soft);
  border: 1px solid rgba(255, 69, 58, 0.3);
  color: #ff8a80;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 16px;
  font-weight: 500;
}
.login-card input, .login-card select {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--separator);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 12px;
  font-family: inherit;
  transition: all var(--transition);
  height: auto;
}
.login-card input:focus, .login-card select:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--ring);
}
.login-card input::placeholder { color: var(--text-tertiary); }
.login-card button {
  width: 100%;
  padding: 13px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: -0.01em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.login-card button:hover { background: var(--blue-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--blue-glow); }
.login-card button:active { transform: translateY(0); }

/* ────────────────────────────────────────────────────────────────────────────
   Topbar — frosted glass, like macOS title bar
   ──────────────────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--separator);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand .logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 2px 8px var(--blue-glow),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.nav-link {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}
.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.nav-link.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}
.nav-link.danger:hover { color: #ff8a80; background: var(--red-soft); }

.user-chip {
  font-size: 13px;
  font-weight: 500;
  color: var(--blue-text);
  background: var(--blue-soft);
  padding: 6px 12px;
  border-radius: 99px;
  margin-left: 8px;
  border: 1px solid rgba(10, 132, 255, 0.2);
}

/* ────────────────────────────────────────────────────────────────────────────
   Page layout
   ──────────────────────────────────────────────────────────────────────────── */

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 36px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}
.page-subtitle {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
}

/* ────────────────────────────────────────────────────────────────────────────
   Buttons — iOS-style
   ──────────────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
  box-shadow: 0 4px 12px var(--blue-glow),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--separator);
  color: var(--text-primary);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--separator-bold);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--red);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red-soft);
  color: #ff8a80;
}

.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }

/* ────────────────────────────────────────────────────────────────────────────
   Filter bar
   ──────────────────────────────────────────────────────────────────────────── */

.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

/* iOS-style segmented control for date ranges */
.range-pills {
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--hairline);
}
.range-pills button {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
  letter-spacing: -0.01em;
}
.range-pills button:hover { color: var(--text-primary); }
.range-pills button.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

input[type="date"], input[type="search"], input[type="text"], select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--separator);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  padding: 7px 13px;
  font-size: 13.5px;
  height: 36px;
  font-family: inherit;
  transition: all var(--transition);
}
input[type="date"] { color-scheme: dark; min-width: 140px; }
select { min-width: 150px; cursor: pointer; }
input[type="search"] { flex: 1; min-width: 200px; max-width: 320px; }
input[type="search"]::placeholder { color: var(--text-tertiary); }
input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--ring);
}
.filterbar .btn-secondary { margin-left: auto; }

/* ────────────────────────────────────────────────────────────────────────────
   KPI cards — like Apple Health metric cards
   ──────────────────────────────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.kpi-card:hover {
  border-color: var(--separator-bold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi-label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.kpi-value-small {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.kpi-value-small .kpi-sub {
  color: var(--text-tertiary);
  font-weight: 500;
  margin-left: 6px;
  font-size: 16px;
}

/* ────────────────────────────────────────────────────────────────────────────
   Cards
   ──────────────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-h {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}
.card-h .badge { color: var(--text-tertiary); font-weight: 500; font-size: 14px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.card-header > h3, .card-header > .card-h { margin: 0; }
.card-header-actions { display: flex; gap: 8px; align-items: center; }

.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-card { min-height: 320px; }
.chart-card canvas { max-height: 260px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

/* ────────────────────────────────────────────────────────────────────────────
   Tables — clean & airy
   ──────────────────────────────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.04); }
.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.data-table .ellipsis { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.proxy-cell { font-weight: 600; color: var(--text-primary); }
.group-badge {
  display: inline-flex;
  align-items: center;
  background: var(--blue-soft);
  color: var(--blue-text);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  margin-left: 10px;
  border: 1px solid rgba(10, 132, 255, 0.2);
  letter-spacing: -0.01em;
}
.bar {
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--indigo));
  border-radius: 99px;
  margin-top: 8px;
  opacity: 0.8;
}
.table-scroll { max-height: 600px; overflow: auto; border-radius: var(--r-sm); }

.empty-state {
  color: var(--text-tertiary);
  text-align: center;
  padding: 48px 20px;
  font-size: 14px;
}
.empty-state .icon {
  font-size: 36px;
  opacity: 0.4;
  margin-bottom: 12px;
  display: block;
}

/* ────────────────────────────────────────────────────────────────────────────
   Settings page
   ──────────────────────────────────────────────────────────────────────────── */

.intro-card { padding: 24px 26px; }
.intro-card p { margin: 8px 0; line-height: 1.6; color: var(--text-secondary); font-size: 14px; }
.intro-card p strong { color: var(--text-primary); font-weight: 600; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 100px;
}
@media (max-width: 1000px) { .settings-grid { grid-template-columns: 1fr; } }

.proxy-list, .group-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 480px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
}
.proxy-item, .group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
  user-select: none;
}
.proxy-item:hover, .group-item:hover {
  background: #48484a;
  border-color: var(--separator);
  transform: translateX(2px);
}
.proxy-item:active, .group-item:active { transform: scale(0.99); }
.proxy-item.selected, .group-item.selected {
  background: var(--blue-soft);
  border-color: var(--blue);
}
.proxy-item-name, .group-item-name {
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.group-item.selected .group-item-name { color: var(--blue-text); font-weight: 600; }
.group-item-name::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--text-tertiary);
  flex-shrink: 0;
  transition: background var(--transition);
}
.group-item.selected .group-item-name::before { background: var(--blue); }
.proxy-item-name::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-quaternary);
  flex-shrink: 0;
}
.proxy-item-count, .group-item-count {
  color: var(--text-tertiary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.member-actions { display: flex; gap: 8px; align-items: center; }
.x-btn {
  background: rgba(255, 69, 58, 0.1);
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 13px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-family: inherit;
  transition: all var(--transition);
  line-height: 1;
}
.x-btn:hover { background: var(--red); color: #fff; transform: scale(1.1); }
.member-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--separator);
}

/* Inline form (for new group / rename / new user) */
.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--blue);
  border-radius: var(--r-sm);
  align-items: center;
  box-shadow: var(--ring);
}
.inline-form input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--separator);
  color: var(--text-primary);
  padding: 8px 13px;
  font-size: 14px;
  font-family: inherit;
  height: 34px;
  border-radius: var(--r-xs);
}
.inline-form input:focus { outline: none; border-color: var(--blue); }
.inline-form .btn { height: 34px; }

/* ────────────────────────────────────────────────────────────────────────────
   Channels
   ──────────────────────────────────────────────────────────────────────────── */

.channel-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px; background: var(--bg-tertiary);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  gap: 14px;
  transition: all var(--transition);
}
.channel-row:hover { border-color: var(--separator); transform: translateX(2px); }
.channel-row .channel-info {
  display: flex; flex-direction: column; gap: 5px;
  min-width: 0; flex: 1;
}
.channel-row .channel-id {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--blue-text);
  font-weight: 500;
}
.channel-row .channel-label {
  font-size: 13px; color: var(--text-tertiary);
}
.channel-row .channel-actions {
  display: flex; gap: 8px; flex-shrink: 0;
}

.sync-status-block {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--separator);
}
.sync-badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600;
  padding: 4px 11px; border-radius: 99px;
  letter-spacing: -0.01em;
  width: fit-content;
}
.sync-badge.pending { background: var(--yellow-soft); color: var(--yellow); border: 1px solid rgba(255, 214, 10, 0.3); }
.sync-badge.running { background: var(--blue-soft); color: var(--blue-text); border: 1px solid rgba(10, 132, 255, 0.3); animation: pulse 2s ease-in-out infinite; }
.sync-badge.done    { background: var(--green-soft); color: var(--green); border: 1px solid rgba(48, 209, 88, 0.3); }
.sync-badge.error   { background: var(--red-soft); color: var(--red); border: 1px solid rgba(255, 69, 58, 0.3); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.sync-progress {
  display: flex; flex-direction: column; gap: 6px;
}
.sync-bar {
  width: 100%; height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px; overflow: hidden;
}
.sync-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--indigo));
  border-radius: 99px;
  transition: width var(--transition-slow);
  box-shadow: 0 0 12px var(--blue-glow);
}
.sync-text {
  font-size: 12.5px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.sync-text.muted { color: var(--text-tertiary); }
.sync-text.error-text { color: #ff8a80; }

@media (max-width: 600px) {
  .channel-row { flex-direction: column; }
  .channel-row .channel-actions { align-self: stretch; }
  .channel-row .channel-actions .btn { flex: 1; }
}

/* ────────────────────────────────────────────────────────────────────────────
   Save bar — floating iOS-style pill
   ──────────────────────────────────────────────────────────────────────────── */

.save-bar {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-glass-thick);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--separator-bold);
  padding: 12px 16px 12px 22px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 18px;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition);
}
.save-bar.dirty { border-color: var(--yellow); }
.save-status {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.save-status::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}
.save-status.dirty { color: var(--yellow); }
.save-status.saved { color: var(--green); }

/* ────────────────────────────────────────────────────────────────────────────
   Toasts — like iOS notification banners
   ──────────────────────────────────────────────────────────────────────────── */

.toast-host {
  position: fixed;
  top: 80px; right: 24px; z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--bg-glass-thick);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--separator-bold);
  color: var(--text-primary);
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 350ms var(--ease-out);
  min-width: 240px;
  max-width: 380px;
  letter-spacing: -0.01em;
}
.toast::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
  box-shadow: 0 0 12px currentColor;
}
.toast.success::before { background: var(--green); }
.toast.error::before { background: var(--red); }
.toast.error { color: #ff8a80; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ────────────────────────────────────────────────────────────────────────────
   Checkbox — iOS-style
   ──────────────────────────────────────────────────────────────────────────── */

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--separator-bold);
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
input[type="checkbox"]:checked {
  background: var(--blue);
  border-color: var(--blue);
}
input[type="checkbox"]:checked::after {
  content: '✓';
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
input[type="checkbox"]:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* ────────────────────────────────────────────────────────────────────────────
   Multi-select dropdown — custom-built (not native <select>)
   ──────────────────────────────────────────────────────────────────────────── */

.multi-select {
  position: relative;
  min-width: 160px;
}
.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--separator);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: -0.01em;
}
.ms-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--separator-bold);
}
.ms-placeholder { color: var(--text-tertiary); }
.ms-value { color: var(--text-primary); font-weight: 500; }
.ms-caret { color: var(--text-tertiary); font-size: 10px; line-height: 1; }

.ms-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 100%;
  width: max-content;
  max-width: 360px;
  background: var(--bg-glass-thick);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--separator-bold);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: msPanelIn 200ms var(--ease-out);
}
@keyframes msPanelIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ms-search-wrap {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--separator);
  align-items: center;
}
.ms-search {
  flex: 1;
  height: 30px !important;
  padding: 4px 10px !important;
  font-size: 13px !important;
  background: rgba(255, 255, 255, 0.06) !important;
}
.ms-clear {
  background: transparent;
  border: 1px solid var(--separator);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all var(--transition);
}
.ms-clear:hover { color: var(--text-primary); border-color: var(--separator-bold); }

.ms-options {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-primary);
  transition: background var(--transition);
  user-select: none;
}
.ms-option:hover { background: rgba(255, 255, 255, 0.06); }
.ms-option.selected { background: var(--blue-soft); }
.ms-option input[type="checkbox"] { margin: 0; }
.ms-option span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ────────────────────────────────────────────────────────────────────────────
   Compare button + comparison cards
   ──────────────────────────────────────────────────────────────────────────── */

#compareBtn.active {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue-text);
}

.compare-card {
  position: relative;
}
.compare-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.compare-prev {
  color: var(--text-tertiary);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.compare-delta {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.delta-up   { color: var(--green); display: inline-flex; align-items: center; gap: 4px; }
.delta-down { color: var(--red);   display: inline-flex; align-items: center; gap: 4px; }
.delta-flat { color: var(--text-tertiary); }

/* ────────────────────────────────────────────────────────────────────────────
   Tools page — text converter tabs + two-column input/output layout
   ──────────────────────────────────────────────────────────────────────────── */

.tools-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tools-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 9px 18px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.tools-tab:hover { color: var(--text-primary); }
.tools-tab.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tools-panel { display: none; }
.tools-panel.active { display: block; }

.tools-config {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}
.tools-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 180px;
}
.tools-field span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.tools-field input {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px !important;
}

.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 800px) {
  .tools-grid { grid-template-columns: 1fr; }
}

.tools-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tools-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px;
  min-height: 30px;
}
.tools-side-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tools-textarea {
  width: 100%;
  min-height: 360px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--separator);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  padding: 14px 16px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  transition: all var(--transition);
}
.tools-textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: var(--ring);
}
.tools-textarea[readonly] {
  background: rgba(0, 0, 0, 0.15);
  cursor: default;
}
.tools-textarea::placeholder {
  color: var(--text-quaternary);
}

/* ────────────────────────────────────────────────────────────────────────────
   Action menu (per-row ⋯ dropdown on admin page)
   ──────────────────────────────────────────────────────────────────────────── */

.action-menu {
  position: relative;
  display: inline-block;
}
.action-menu-trigger {
  font-size: 16px !important;
  padding: 0 10px !important;
  letter-spacing: 0;
}
.action-menu-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 220px;
  background: var(--bg-glass-thick);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--separator-bold);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  flex-direction: column;
  gap: 2px;
}
.action-menu-panel.open {
  display: flex;
  animation: msPanelIn 200ms var(--ease-out);
}
.action-menu-item {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--transition);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.action-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.action-menu-item.danger {
  color: var(--red);
}
.action-menu-item.danger:hover {
  background: var(--red-soft);
  color: #ff8a80;
}
.action-menu-divider {
  height: 1px;
  background: var(--separator);
  margin: 4px 4px;
}

/* Channel rename inline edit (pencil icon + input) */
.channel-label-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.channel-label-pencil {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all var(--transition);
}
.channel-label-pencil:hover {
  color: var(--blue-text);
  background: var(--blue-soft);
}
.channel-label-input {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid var(--blue) !important;
  border-radius: 6px !important;
  color: var(--text-primary) !important;
  padding: 4px 8px !important;
  font-size: 13px !important;
  height: 28px !important;
  font-family: inherit;
  box-shadow: var(--ring);
  width: 200px;
}

/* Items card on dashboard — replaces the old "by hour" chart slot */
.items-card {
  display: flex;
  flex-direction: column;
}
.items-card .card-header {
  margin-bottom: 12px;
  flex-wrap: nowrap;
  gap: 8px;
}
.items-card .items-scroll {
  flex: 1;
  max-height: 280px;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 4px;
}
.items-card .data-table {
  font-size: 13px;
}
.items-card .data-table th,
.items-card .data-table td {
  padding: 7px 10px;
}
.items-card .data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
}