/* ==========================================================
   AUTOSHORT MODERN DASHBOARD & REAL ANALYTICS ENGINE
   Clean, purpose-built, and 100% functional architecture
   ========================================================== */

:root {
  /* Light Theme */
  --bg-page: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --bg-hover: #f1f5f9;

  --border-light: #e2e8f0;
  --border-card: #e2e8f0;
  --border-focus: #ef4444;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* AutoShort Accents */
  --brand-primary: #ef4444;
  --brand-primary-hover: #dc2626;
  --brand-light: #fee2e2;

  --chart-visitors: #ef4444;
  --chart-unique: #8b5cf6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] {
  --bg-page: #090d16;
  --bg-sidebar: #101626;
  --bg-card: #131c31;
  --bg-input: #0c1220;
  --bg-hover: #1b2640;

  --border-light: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.09);
  --border-focus: #f43f5e;

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --brand-light: rgba(239, 68, 68, 0.18);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================
   LAYOUT STRUCTURE: SIDEBAR + WORKSPACE
   ========================================================== */

.sid-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* SIDEBAR */
.sid-sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 150;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidebar-header {
  padding: 24px 20px 16px;
  display: flex;
  align-items: center;
}

.sid-brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-text-main {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

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

/* SIDEBAR NAVIGATION */
.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item .nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active .nav-link {
  background: var(--brand-light);
  color: var(--brand-primary);
  font-weight: 700;
}

.nav-item.active .nav-icon {
  color: var(--brand-primary);
}

.nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  color: #64748b;
  transition: color 0.15s;
}

.nav-label {
  flex: 1;
}

/* SIDEBAR BOTTOM */
.sidebar-bottom {
  padding: 16px 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-sidebar);
}

.btn-sidebar-create {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.88rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-hover);
}

.user-avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.user-name-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.user-options-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
}

/* ==========================================================
   TOPBAR HEADER
   ========================================================== */

.sid-main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.sid-topbar {
  height: 62px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-main);
  cursor: pointer;
}

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

.topbar-title-wrap .title-icon {
  font-size: 1.15rem;
  color: var(--brand-primary);
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.status-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.domain-pill-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* ==========================================================
   CONTENT AREA & CONTROLS TOOLBAR
   ========================================================== */

.sid-content-area {
  padding: 24px 32px 40px;
  flex: 1;
}


.analytics-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.link-filter-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.link-filter-wrapper .filter-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.select-clean {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 8px 14px 8px 32px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-sm);
}

.date-dropdown-wrapper {
  position: relative;
}

.date-range-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.date-range-btn:hover, .date-range-btn.open {
  border-color: var(--brand-primary);
}

.caret-icon {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-outline-clean {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.btn-outline-clean:hover {
  background: var(--bg-hover);
}

/* ==========================================================
   INTERACTIVE POPUP CALENDAR
   ========================================================== */

.calendar-picker-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 35px -4px rgba(0, 0, 0, 0.15);
  padding: 16px;
  width: 320px;
  animation: calFadeIn 0.15s ease-out;
}

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

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

.cal-selects {
  display: flex;
  gap: 6px;
}

.cal-dropdown {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

.cal-nav-arrows {
  display: flex;
  gap: 4px;
}

.cal-arrow-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
}

.cal-arrow-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  position: relative;
  transition: all 0.1s;
}

.cal-day-cell:hover:not(.empty):not(.range-start):not(.range-end) {
  background: var(--bg-hover);
}

.cal-day-cell.other-month {
  color: #cbd5e1;
}

.cal-day-cell.in-range {
  background: var(--brand-light);
  color: var(--brand-primary);
  border-radius: 0;
}

.cal-day-cell.range-start {
  background: var(--brand-primary) !important;
  color: #ffffff !important;
  border-radius: 50% 0 0 50% !important;
  font-weight: 700;
}

.cal-day-cell.range-end {
  background: var(--brand-primary) !important;
  color: #ffffff !important;
  border-radius: 0 50% 50% 0 !important;
  font-weight: 700;
}

.cal-day-cell.range-end::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  background: #ffffff;
  border-radius: 50%;
}

.cal-day-cell.single-selected {
  background: var(--brand-primary) !important;
  color: #ffffff !important;
  border-radius: 50% !important;
  font-weight: 700;
}

/* ==========================================================
   STACKED BAR CHART
   ========================================================== */

.analytics-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.chart-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.red { background: var(--chart-visitors); }
.legend-dot.purple { background: var(--chart-unique); }

.chart-hint-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stacked-chart-viewport {
  position: relative;
  height: 240px;
  margin-left: 36px;
  margin-bottom: 24px;
}

.chart-y-axis {
  position: absolute;
  top: 0;
  left: -36px;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.y-tick {
  display: flex;
  align-items: center;
  width: 100%;
}

.y-tick span {
  width: 30px;
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 8px;
  font-family: 'JetBrains Mono', monospace;
}

.y-tick .grid-line {
  flex: 1;
  border-top: 1px dashed var(--border-light);
}

.y-tick .grid-line.zero {
  border-top: 1px solid #cbd5e1;
}

.chart-bars-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 0 10px;
}

.chart-bar-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
  cursor: pointer;
  flex: 1;
  max-width: 60px;
}

.stacked-bar-fill {
  width: 32px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s;
}

.chart-bar-column:hover .stacked-bar-fill {
  transform: scaleY(1.03);
  filter: brightness(1.08);
}

.bar-segment-unique {
  background: var(--chart-unique);
  width: 100%;
  transition: height 0.3s;
}

.bar-segment-visitors {
  background: var(--chart-visitors);
  width: 100%;
  transition: height 0.3s;
}

.bar-date-label {
  position: absolute;
  bottom: -22px;
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}

/* ==========================================================
   PERFORMANCE TABLE & DEEP DIVES
   ========================================================== */

.performance-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.perf-header {
  margin-bottom: 16px;
}

.perf-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
}

.perf-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.real-analytics-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.real-analytics-table th {
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-light);
  color: var(--text-secondary);
  font-weight: 700;
}

.real-analytics-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.real-analytics-table tr:hover {
  background: var(--bg-hover);
}

.deep-dive-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.deep-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.deep-card h4 {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.breakdown-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

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

.breakdown-progress-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 999px;
  transition: width 0.3s;
}

/* ==========================================================
   QR STUDIO VIEW
   ========================================================== */

.qr-studio-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.qr-studio-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.qr-studio-header p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.qr-studio-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
}

.color-picker-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s;
}

.color-btn.active {
  border-color: #0f172a;
  transform: scale(1.1);
}

.qr-preview-url {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--brand-primary);
  word-break: break-all;
}

.qr-actions-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.qr-display-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 30px;
}

.qr-box-wrap {
  background: #ffffff;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.qr-hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================
   ACTIVITY STREAM TABLE
   ========================================================== */

.activity-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.activity-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
}

.activity-header p {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.live-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #10b981;
}

.live-pulse {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulseLive 1.5s infinite;
}

@keyframes pulseLive {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.activity-table-wrap {
  overflow-x: auto;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.activity-table th {
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-light);
  color: var(--text-secondary);
  font-weight: 700;
  text-align: left;
}

.activity-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

/* ==========================================================
   SETTINGS & CLOUD GRID
   ========================================================== */

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.settings-card h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.settings-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.settings-box {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.settings-box h3 {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.settings-box p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex: 1;
}

/* ==========================================================
   SHORTENER VIEW (QUICK HERO & CARDS)
   ========================================================== */

.links-section {
  margin-top: 24px;
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-left h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.count-badge {
  background: var(--brand-light);
  color: var(--brand-primary);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

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

.search-box-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box-wrap i {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

.search-box-wrap input {
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 0.85rem;
  outline: none;
}

.links-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.link-card:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.link-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.short-url-link {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--brand-primary);
}

/* ==========================================================
   MODALS: LINK & WHATSAPP PREVIEW
   ========================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 880px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: modalPop 0.2s ease-out;
  overflow: hidden;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 22px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-card);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-sm.delete:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.input-control, .textarea-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
}

.input-control:focus, .textarea-control:focus {
  border-color: var(--border-focus);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.slug-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  overflow: hidden;
}

.slug-domain-addon {
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-hover);
}

.slug-input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
}

.btn-random-slug {
  background: none;
  border: none;
  padding: 10px 14px;
  color: var(--text-muted);
  cursor: pointer;
}

.upload-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.upload-dropzone:hover {
  border-color: var(--brand-primary);
}

.dropzone-icon {
  font-size: 2rem;
  color: #94a3b8;
  margin-bottom: 8px;
}

.dropzone-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.dropzone-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.dropzone-active img {
  max-height: 120px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.url-toggle-bar {
  margin-top: 8px;
}

.btn-text-toggle {
  background: none;
  border: none;
  color: var(--brand-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-split-view {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}

.preview-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.whatsapp-bubble-mockup {
  background: #efeae2;
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid #d1d5db;
}

.wa-card {
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 8px;
}

.wa-img-wrap {
  width: 100%;
  height: 140px;
  overflow: hidden;
  background: #e2e8f0;
}

.wa-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wa-content {
  padding: 10px;
}

.wa-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.wa-desc {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.35;
  margin-bottom: 6px;
}

.wa-domain {
  font-size: 0.7rem;
  color: #94a3b8;
  text-transform: uppercase;
}

.wa-text-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #0284c7;
}

.wa-time {
  font-size: 0.68rem;
  color: #94a3b8;
}

.wa-ticks {
  color: #38bdf8;
  margin-left: 2px;
}

.preview-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 12px;
  display: flex;
  gap: 6px;
}

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #ffffff;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease-out;
}

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

/* PRINT STYLES FOR EXPORT PDF */
@media print {
  .sid-sidebar, .sid-topbar, #btnExportPdf, #btnDownloadCsv, .link-filter-wrapper, .date-dropdown-wrapper {
    display: none !important;
  }
  .sid-layout { display: block; }
  .sid-main-wrapper { height: auto; overflow: visible; }
  .sid-content-area { padding: 0; }
  .analytics-chart-card, .performance-table-card {
    box-shadow: none;
    border: 1px solid #000;
    break-inside: avoid;
  }
}

/* RESPONSIVE */
@media (max-width: 1024px) {
  .deep-dive-grid { grid-template-columns: 1fr; }

  .qr-studio-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-menu-toggle { display: block; }
  .sid-sidebar {
    position: fixed;
    left: -270px;
    transition: left 0.25s;
  }
  .sid-sidebar.open { left: 0; }

  .modal-split-view { grid-template-columns: 1fr; }
}

/* Comfortable workspace, keyboard access, and small-screen layouts. */
:root { --text-muted: #64748b; }
[data-theme="dark"] { --text-muted: #94a3b8; color-scheme: dark; }
button, input, select, textarea { font: inherit; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 3px solid #3b82f6; outline-offset: 3px; }
[hidden] { display: none !important; }
.sid-main-wrapper { height: auto; min-height: 100dvh; overflow: visible; }
.sid-sidebar { height: 100dvh; }
.sid-content-area { width: 100%; max-width: 1600px; margin-inline: auto; }
.sid-topbar { min-height: 72px; height: auto; gap: 16px; padding-block: 12px; }
.topbar-left, .topbar-right, .topbar-title-wrap { min-width: 0; }
.topbar-title { font-size: clamp(.95rem, 1.4vw, 1.15rem); }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.storage-notice { margin: 20px 32px 0; padding: 12px 16px; border: 1px solid var(--border-card); border-left: 3px solid #3b82f6; border-radius: 10px; font-size: .8rem; color: var(--text-secondary); background: var(--bg-card); }
.analytics-controls-bar .controls-left, .analytics-controls-bar .controls-right { flex-wrap: wrap; min-width: 0; }
.link-filter-wrapper, .select-clean { max-width: 100%; min-width: 0; }
.section-toolbar, .toolbar-right { flex-wrap: wrap; gap: 12px; }

.link-title { overflow-wrap: anywhere; }

.short-url-link, .qr-preview-url { overflow-wrap: anywhere; word-break: break-word; }

.mobile-menu-toggle, .modal-close { min-width: 40px; min-height: 40px; }

.link-status { border-radius: 6px; padding: 2px 8px; background: var(--bg-hover); color: var(--text-secondary); }
.status-active { color: #15803d; background: #dcfce7; }
.status-paused, .status-expired { color: #92400e; background: #fef3c7; }
.status-protected { color: #6d28d9; background: #ede9fe; }

.search-empty { padding: 24px; color: var(--text-secondary); }
.modal-open { overflow: hidden; }
.modal-dialog { max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain; }
.modal-header { position: sticky; top: 0; background: var(--bg-card); z-index: 3; }
.modal-footer { position: sticky; bottom: 0; background: var(--bg-card); z-index: 3; }
.modal-split-view > *, .settings-grid > *, .qr-studio-grid > * { min-width: 0; }
.advanced-options { border: 1px solid var(--border-card); border-radius: 10px; padding: 12px; margin-bottom: 20px; }
.advanced-options summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.advanced-options .form-group:last-child { margin-bottom: 0; }
.utm-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.upload-dropzone.dragging { border-color: var(--brand-primary); background: var(--brand-light); }
.settings-action-btns, .qr-actions-row { flex-wrap: wrap; }
.qr-box-wrap { background: white; padding: 8px; border-radius: 12px; }
.qr-box-wrap canvas { max-width: 100%; height: auto !important; }
.table-responsive, .activity-table-wrap { overflow-x: auto; max-width: 100%; overscroll-behavior-inline: contain; }
.real-analytics-table, .activity-table { min-width: 640px; }
.menu-backdrop { position: fixed; inset: 0; border: 0; background: #0f172a88; z-index: 140; }
.calendar-picker-popup { max-width: calc(100vw - 32px); }
@media (max-width: 1200px) {
  .sid-topbar { padding-inline: 24px; }

}
@media (max-width: 768px) {
  .sid-sidebar { top: 0; box-shadow: var(--shadow-lg); }
  .sid-topbar { padding: 12px 16px; min-height: 64px; flex-wrap: wrap; gap: 8px; }
  .topbar-left { flex: 1; }
  .topbar-title-wrap { gap: 8px; }
  .topbar-title { line-height: 1.4; }
  .topbar-right { gap: 6px; }
  .domain-pill-btn { display: none; }
  .status-pill-btn { padding: 6px 9px; font-size: .7rem; max-width: 140px; }
  .sid-content-area { padding: 20px 16px 32px; }
  .storage-notice { margin: 16px 16px 0; font-size: .75rem; }
  .controls-left, .controls-right { width: 100%; }
  .controls-left > * { flex: 1; }
  .controls-right > button { flex: 1; padding-inline: 8px; }
  .date-range-btn { width: 100%; justify-content: center; padding-inline: 8px; }
  .calendar-picker-popup { position: fixed; top: 145px; left: 16px; right: 16px; width: auto; z-index: 130; }

  .analytics-chart-card, .qr-studio-card, .settings-card { padding: 18px 14px; }
  .toolbar-right { width: 100%; }

  .link-card { padding: 16px; }

  .modal-backdrop { padding: 8px; }
  .modal-dialog { max-height: calc(100dvh - 16px); border-radius: 14px; }
  .modal-header, .modal-body, .modal-footer { padding: 14px; }
  .modal-header h3 { font-size: .95rem; }
  .modal-split-view { gap: 20px; }
  .modal-footer .btn { flex: 1; padding-inline: 8px; }
  input, textarea, select { font-size: 16px !important; }
  .utm-fields { grid-template-columns: 1fr; }
  .toast-container { left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .toast { font-size: .8rem; }
}
@media (max-width: 380px) {
  .sid-topbar { align-items: flex-start; }
  .topbar-right { width: 100%; justify-content: flex-end; }

}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .storage-notice, .menu-backdrop, .toast-container { display: none !important; }
  .sid-content-area { max-width: none; }
  .table-responsive { overflow: visible; }
}
.stacked-bar-fill { width: 70%; max-width: 32px; min-width: 1px; }

.chart-legend { flex-wrap: wrap; gap: 10px; }
@media (max-width: 768px) {

  .chart-legend { font-size: .72rem; }
  .bar-date-label { font-size: .64rem; }
}

.chart-top-bar { flex-wrap: wrap; gap: 12px; }
@media (max-width: 768px) {
  .chart-top-bar { flex-direction: column; align-items: flex-start; }
  .chart-hint-label { font-size: .7rem; }
  .search-box-wrap { flex: 1 1 100%; min-width: 0; }
  .search-box-wrap input { width: 100%; min-width: 0; }
  .link-card { flex-wrap: wrap; gap: 16px; }

}

/* Total visits and unique visitors are related measures, so show them side by side. */
.stacked-bar-fill { flex-direction: row; align-items: flex-end; gap: 2px; background: transparent; }
.bar-segment-unique, .bar-segment-visitors { width: calc(50% - 1px); border-radius: 3px 3px 0 0; }

/* Domain management */
.domain-settings { grid-column: 1 / -1; min-width: 0; }
.domain-settings details { padding: 14px; border: 1px solid var(--border-color, #dbe3ee); border-radius: 10px; margin-top: 16px; }
.domain-settings summary { cursor: pointer; font-weight: 600; }
.domain-settings details p { margin: 10px 0; }
.domain-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.domain-list { display: grid; gap: 10px; margin-top: 16px; }
.domain-item { border: 1px solid var(--border-color, #dbe3ee); border-radius: 10px; padding: 12px; min-width: 0; }
.domain-item strong, .domain-details code { overflow-wrap: anywhere; word-break: break-word; }
.domain-details { padding: 14px; border: 1px solid var(--border-color, #dbe3ee); border-radius: 10px; margin-top: 12px; min-width: 0; }
.domain-settings button:disabled { cursor: not-allowed; opacity: .5; }
