/* SheetStudio — Modern Professional Dark/Light Theme with Full RTL & LTR Support */

:root {
  --font-ar: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family: var(--font-ar);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --accent: #10b981;
  --accent-hover: #059669;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --amber: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);

  --sidebar-width: 276px;
  --topbar-height: 64px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #0f172a;
  --surface: #111c33;
  --surface-2: #17243f;
  --surface-hover: #1d2d4e;
  --border: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --shadow: 0 12px 32px rgba(2, 6, 23, 0.45);
  --shadow-sm: 0 4px 14px rgba(2, 6, 23, 0.3);
  --table-head: #15213a;
  --table-zebra: rgba(255, 255, 255, 0.018);
  --table-foot: #132238;
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-subtle: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.05);
  --table-head: #f8fafc;
  --table-zebra: rgba(15, 23, 42, 0.02);
  --table-foot: #ecfdf5;
}

html[dir="ltr"] {
  --font-family: var(--font-en);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.full-width { width: 100%; }
.muted-text { color: var(--text-muted); font-size: 12.5px; }

/* App Shell */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), transform var(--transition);
  z-index: 30;
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border-inline-end: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.56);
  backdrop-filter: blur(2px);
  z-index: 25;
}

@media (min-width: 901px) {
  .sidebar-backdrop {
    display: none !important;
  }
}

.sidebar-brand {
  height: var(--topbar-height);
  padding: 0 14px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  min-width: 0;
}

.brand-logo svg {
  width: 34px;
  height: 34px;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-section {
  padding: 14px 12px 6px;
}

.sheets-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.section-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.count-pill {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.sheet-nav-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
}

.sidebar-empty {
  padding: 16px 10px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.nav-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: start;
  transition: background var(--transition), color var(--transition);
}

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

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-icon svg {
  width: 17px;
  height: 17px;
  display: block;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
}

.nav-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.nav-item.active .nav-badge {
  background: rgba(16, 185, 129, 0.22);
  color: var(--accent);
}

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

.wb-status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wb-status-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wb-filename {
  font-size: 12.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dirty-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

.wb-status-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.provider-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 6px;
  font-weight: 600;
}

.wb-footer-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

/* Main Column */
.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.url-bar-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 680px;
}

.url-input-wrap {
  position: relative;
  flex: 1;
  min-width: 160px;
}

.url-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.url-icon svg {
  width: 15px;
  height: 15px;
  display: block;
}

.url-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.url-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ms-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}

.ms-dot.connected {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all var(--transition);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-sm { padding: 6px 12px; font-size: 12.5px; height: 35px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; height: 48px; }

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-accent {
  background: var(--blue);
  color: #fff;
}
.btn-accent:hover { filter: brightness(1.08); }

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); }

.btn:disabled, .icon-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none !important;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn.text-btn { font-size: 12px; font-weight: 800; font-family: var(--font-en); }

.icon-btn-sm {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn-sm svg { width: 15px; height: 15px; }
.icon-btn-sm:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn-sm.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Main Scrollable Area */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 36px;
}

/* Welcome View */
.welcome-view {
  max-width: 980px;
  margin: 18px auto 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: -60% 15% auto;
  height: 240px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.18), transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25);
}

.hero-title {
  font-size: clamp(22px, 3vw, 31px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.hero-desc {
  max-width: 680px;
  margin: 0 auto 24px;
  color: var(--text-muted);
  font-size: 14.5px;
}

.hero-url-form {
  display: flex;
  gap: 10px;
  max-width: 740px;
  margin: 0 auto 16px;
}

.hero-url-input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 14px;
}

.hero-url-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.provider-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}

.pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.hero-secondary-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.recent-links {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: start;
}

.recent-header {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.recent-item:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

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

.recent-item-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

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

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.feature-icon svg { width: 20px; height: 20px; }
.feature-icon.emerald { background: rgba(16, 185, 129, 0.14); color: #10b981; }
.feature-icon.blue { background: rgba(59, 130, 246, 0.14); color: #3b82f6; }
.feature-icon.purple { background: rgba(139, 92, 246, 0.14); color: #8b5cf6; }

.feature-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 13px; color: var(--text-muted); }

/* Views & Headers */
.view-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

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

.card-header h3 {
  font-size: 15.5px;
  font-weight: 700;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
}

.sheet-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.sheet-overview-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition);
}

.sheet-overview-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.sheet-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sheet-card-name {
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-card-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.col-chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* Sheet Header */
.sheet-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sheet-badge-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  overflow-x: auto;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all var(--transition);
}

.tab-btn svg { width: 16px; height: 16px; }
.tab-btn:hover { background: var(--surface-hover); color: var(--text); }
.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.3);
}

.tab-panel { display: flex; flex-direction: column; gap: 14px; }

/* Toolbar */
.toolbar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.search-box svg {
  position: absolute;
  top: 50%;
  inset-inline-start: 11px;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
}

.search-box input {
  width: 100%;
  height: 36px;
  padding-inline-start: 34px;
  padding-inline-end: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.toolbar-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.mini-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  padding: 0 6px;
  border-radius: 999px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
}

.filter-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
}

.bulk-actions { display: flex; gap: 8px; }

/* Table */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-scroll {
  overflow-x: auto;
  max-height: 560px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--table-head);
  border-bottom: 1px solid var(--border-strong);
  padding: 11px 12px;
  text-align: start;
  font-weight: 700;
  white-space: nowrap;
  user-select: none;
}

.data-table thead th.sortable {
  cursor: pointer;
}
.data-table thead th.sortable:hover {
  background: var(--surface-hover);
}

.th-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.type-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-faint);
  font-family: var(--font-en);
}

.sort-indicator {
  color: var(--accent);
  font-size: 11px;
}

.data-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  max-width: 290px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr:nth-child(even) {
  background: var(--table-zebra);
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

.data-table tbody td.num-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.data-table tbody td.editable-cell {
  cursor: cell;
}

.data-table tbody td.editing {
  padding: 3px 6px;
}

.inline-edit-input {
  width: 100%;
  min-width: 90px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 2px solid var(--accent);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.data-table tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--table-foot);
  border-top: 2px solid var(--border-strong);
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.foot-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.row-actions-cell {
  width: 98px;
  text-align: center;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-indicator {
  font-size: 12.5px;
  font-weight: 700;
  padding: 0 6px;
}

/* Inputs & Controls */
.input, .select-sm {
  height: 38px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}

.select-sm {
  height: 32px;
  width: auto;
  padding: 0 8px;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.input {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.form-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.align-end { justify-content: flex-end; }

/* Progress bar & badges */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}

.progress-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* Pivot & Charts */
.pivot-results-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 16px;
}

.chart-box {
  width: 100%;
  height: 290px;
  position: relative;
}

.chart-box.tall { height: 340px; }
.chart-box.xl { height: 420px; }

.chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 20;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s ease;
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 175px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: start;
  padding: 8px 11px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

.modal-dialog {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog.modal-wide {
  max-width: 880px;
}

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

.modal-header h3 { font-size: 16px; font-weight: 800; }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tool-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-section h4 { font-size: 14px; font-weight: 700; }

.col-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.col-manage-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.device-code-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.device-code-value {
  font-family: var(--font-en);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 8px 0;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.loader-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 34px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

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

/* Toasts — positioned at top-end so they never cover pagination or modal buttons */
.toast-container {
  position: fixed;
  top: 74px;
  inset-inline-end: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  max-width: min(410px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 600;
  white-space: pre-line;
  animation: slideIn 0.2s ease;
}

.toast.error { border-inline-start-color: var(--danger); }
.toast.warn { border-inline-start-color: var(--amber); }

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

/* Full-Window Drag & Drop Overlay for Zero-Code File Drop */
.dropzone-overlay {
  position: fixed;
  inset: 14px;
  border-radius: var(--radius-xl);
  border: 3px dashed var(--accent);
  background: rgba(11, 17, 32, 0.86);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 400;
  color: #fff;
  pointer-events: none;
}

.dropzone-overlay h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

/* Non-Coder Guide Step Cards */
.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-step-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.guide-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-step-card h4 {
  font-size: 13.5px;
  font-weight: 800;
  margin-bottom: 3px;
}

.guide-step-card p {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Smart Status Badges & Power Tools Studio */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.ok {
  background: rgba(16, 185, 129, 0.16);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.warn {
  background: rgba(245, 158, 11, 0.16);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.err {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.info {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.recipes-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.11), rgba(59, 130, 246, 0.09));
  border: 1px solid rgba(16, 185, 129, 0.32);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recipes-banner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.recipes-banner-head h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  text-align: start;
  font-family: inherit;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all var(--transition);
}

.recipe-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.recipe-card-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
}

.recipe-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.smart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.smart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.smart-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.smart-card-head h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
}

.smart-card-head p {
  font-size: 12px;
  color: var(--text-muted);
}

.check-pills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  max-height: 130px;
  overflow-y: auto;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.check-pill input {
  accent-color: var(--accent);
}

@media (max-width: 1080px) {
  .smart-grid { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 1080px) {
  .overview-grid, .pivot-results-grid { grid-template-columns: 1fr; }
  .form-grid-4, .form-grid-5 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    box-shadow: var(--shadow);
  }
}

@media (max-width: 768px) {
  .hide-sm { display: none; }
  .topbar {
    height: auto;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-left {
    order: 2;
    flex: 1 1 100%;
    width: 100%;
  }
  .topbar-right {
    order: 1;
    width: 100%;
    justify-content: space-between;
  }
  .url-bar-form {
    max-width: none;
    width: 100%;
  }
  .url-input-wrap {
    min-width: 0;
  }
  .main-content {
    padding: 14px 12px 28px;
  }
  .hero-card {
    padding: 24px 16px;
  }
  .hero-url-form { flex-direction: column; }
  .form-grid-2, .form-grid-4, .form-grid-5 { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  .tabs-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .tab-btn {
    justify-content: center;
    padding: 8px 8px;
    font-size: 12.5px;
  }
}

/* Ready Zero-Data Excel Templates Gallery */
.templates-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 26px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.templates-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.templates-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 8px;
}

.templates-title {
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 800;
  margin-bottom: 6px;
}

.templates-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 780px;
  line-height: 1.6;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.templates-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  max-height: 64vh;
  overflow-y: auto;
  padding: 2px;
}

.template-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all var(--transition);
}

.template-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.template-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.template-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  background: rgba(16, 185, 129, 0.14);
  flex-shrink: 0;
}

.template-icon-badge.blue { background: rgba(59, 130, 246, 0.14); }
.template-icon-badge.purple { background: rgba(139, 92, 246, 0.14); }

.template-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.template-cat-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.template-card-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 4px;
  line-height: 1.4;
}

.template-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.template-sheets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.template-sheet-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.template-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.template-card-actions .btn-use-tpl {
  flex: 1;
}

/* Print Styles */
@media print {
  .sidebar, .topbar, .tabs-bar, .toolbar-card, .page-header-actions, .table-footer, .row-actions-cell {
    display: none !important;
  }
  .app-shell, .main-column, .main-content, .table-scroll {
    height: auto !important;
    overflow: visible !important;
    max-height: none !important;
  }
  body { background: #fff; color: #000; }
}
