/* Nextora POS Cloud Analytics - Owner Portal Design System */
:root {
  --bg-main: #0c1310;
  --bg-card: #131c18;
  --bg-card-hover: #18241f;
  --bg-elevated: #1a2822;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.4);
  --accent: #10b981;
  --accent-light: #34d399;
  --accent-glow: rgba(16, 185, 129, 0.15);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --info: #0ea5e9;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hanken Grotesk", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

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

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

body.drawer-open {
  overflow: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

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

/* ==========================================================================
   Mobile Top App Bar (< 768px)
   ========================================================================== */
.mobile-app-bar {
  display: none;
  position: relative;
  align-items: center;
  height: 56px;
  padding: 0 16px;
  background-color: #090e0c;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  box-sizing: border-box;
}

.mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.mobile-menu-btn:hover {
  background-color: var(--bg-card);
  border-color: var(--border-focus);
}

.mobile-menu-btn:focus-visible {
  background-color: var(--bg-card);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
  outline: none;
}

.mobile-brand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 130px);
  justify-content: center;
  pointer-events: auto;
  z-index: 1;
  text-decoration: none;
  user-select: none;
}

.mobile-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
}

.mobile-brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  text-align: left;
}

.mobile-brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-brand-subtitle {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-light);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Backdrop (Mobile Drawer Overlay) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Layout & Navigation
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

.sidebar {
  width: 260px;
  background-color: #090e0c;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-close-btn:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.12);
}

.brand-badge {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 0 12px var(--accent-glow);
  flex-shrink: 0;
}

.brand-logo {
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
  display: block;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--accent-light);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-menu {
  padding: 16px 12px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  min-height: 44px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.nav-item.active {
  background-color: var(--bg-card);
  color: var(--accent-light);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background-color: rgba(0, 0, 0, 0.2);
}

.user-profile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-info {
  overflow: hidden;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-restaurant {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  overflow-x: hidden;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.top-header {
  height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(12, 19, 16, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

#header-restaurant-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}

.sync-dot.offline {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.sync-dot.warning {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

.sync-dot.neutral {
  background-color: var(--text-dim);
  box-shadow: none;
}

/* ==========================================================================
   Sidebar Restaurant Status Section
   ========================================================================== */
.sidebar-status-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-status-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.sidebar-status-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sidebar-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.15s ease;
  user-select: none;
}

.sidebar-status-item .status-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.sidebar-status-item .sub-dot,
.sidebar-status-item .sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-status-item.sync-badge {
  color: var(--text-muted);
}

.sidebar-status-item.sync-synced {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.28);
  color: #34d399;
}

.sidebar-status-item.sync-pending {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.28);
  color: #fbbf24;
}

.sidebar-status-item.sync-offline,
.sidebar-status-item.sync-revoked {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.28);
  color: #f87171;
}

.sidebar-status-item.sync-unpaired {
  background-color: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

/* ==========================================================================
   Subscription Status Badges
   ========================================================================== */
.sub-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
  user-select: none;
}

.sub-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-dim);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

/* Active: Emerald Green */
.sub-badge.sub-active {
  background-color: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}
.sub-badge.sub-active .sub-dot {
  background-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

/* Warning: Amber (Expiring Soon / Expires Today) */
.sub-badge.sub-warning {
  background-color: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}
.sub-badge.sub-warning .sub-dot {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

/* Expired: Crimson / Danger Red */
.sub-badge.sub-expired {
  background-color: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.sub-badge.sub-expired .sub-dot {
  background-color: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

/* Grace Period: Warm Orange */
.sub-badge.sub-grace {
  background-color: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.35);
  color: #fb923c;
}
.sub-badge.sub-grace .sub-dot {
  background-color: #f97316;
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.7);
}

/* Lifetime: Sky Blue */
.sub-badge.sub-lifetime {
  background-color: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}
.sub-badge.sub-lifetime .sub-dot {
  background-color: #0284c7;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.7);
}

/* Unavailable / Loading: Neutral Subdued */
.sub-badge.sub-unavailable,
.sub-badge.sub-loading {
  background-color: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text-dim);
}
.sub-badge.sub-unavailable .sub-dot,
.sub-badge.sub-loading .sub-dot {
  background-color: var(--text-dim);
  box-shadow: none;
}

/* Compact variant for narrow mobile headers */
.sub-badge.sub-compact {
  padding: 4px 9px;
  font-size: 11px;
  gap: 6px;
}
.sub-badge.sub-compact .sub-dot {
  width: 6px;
  height: 6px;
}

/* Date filter bar */
.date-selector-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.date-selector-group::-webkit-scrollbar {
  display: none;
}

.date-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  min-height: 34px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.date-btn:hover {
  color: var(--text-main);
}

.date-btn.active {
  background-color: var(--bg-elevated);
  color: #fff;
  font-weight: 600;
}

/* Page body */
.page-body {
  padding: 28px;
  flex: 1;
  width: 100%;
  min-width: 0;
}

/* ==========================================================================
   Grid & Cards System
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
  overflow: hidden;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

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

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-exact {
  background-color: var(--success-bg);
  color: var(--accent-light);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-partial {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-unavailable {
  background-color: rgba(148, 163, 184, 0.1);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.kpi-value {
  font-size: clamp(22px, 3.5vw, 26px);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 6px;
  word-break: break-word;
}

.kpi-subtext {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

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

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

/* Charts */
.chart-container {
  width: 100%;
  min-width: 0;
  height: 260px;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  width: 100%;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  padding: 12px 16px;
  background-color: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

tr.clickable-row {
  cursor: pointer;
  transition: background-color 0.15s;
}

tr.clickable-row:hover {
  background-color: var(--bg-card-hover);
}

/* Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-completed {
  background-color: var(--success-bg);
  color: var(--accent-light);
}

.status-cancelled {
  background-color: var(--danger-bg);
  color: var(--danger);
}

.status-paid {
  background-color: var(--success-bg);
  color: var(--accent-light);
}

.status-voided {
  background-color: var(--danger-bg);
  color: var(--danger);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 38px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 0 14px var(--accent-glow);
}

.btn-secondary {
  background-color: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background-color: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.2);
}

.btn-icon {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: #121a16;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin: auto;
}

.modal-card table {
  min-width: 100%;
}

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

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: rgba(0, 0, 0, 0.2);
}

/* Pairing Code Display */
.pairing-code-box {
  background-color: #080d0b;
  border: 2px dashed rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 4vw, 24px);
  text-align: center;
  margin: 16px 0;
  overflow: hidden;
}

.pairing-code-text {
  font-size: clamp(26px, 8vw, 42px);
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--accent-light);
  font-family: var(--font-mono);
  margin-bottom: 8px;
  word-break: break-all;
}

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

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  min-height: 40px;
  background-color: #0b110e;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

/* Auth View */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 60%), #0c1310;
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background-color: #121a16;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 5vw, 32px);
  box-shadow: var(--shadow-lg);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1200;
  max-width: calc(100vw - 48px);
}

.toast {
  padding: 12px 18px;
  background-color: #1a2520;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease;
}

.toast-success {
  border-left: 4px solid var(--accent);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-info {
  border-left: 4px solid #38bdf8;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* Tablet & Smaller Laptops (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar {
    width: 210px;
  }

  .top-header {
    padding: 0 20px;
  }

  .page-body {
    padding: 20px;
  }

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

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

/* Desktop Wide Screens (>= 1024px) */
@media (min-width: 1024px) {
  .sidebar {
    width: 260px;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

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

/* Mobile & Small Tablets (< 768px) */
@media (max-width: 767px) {
  .mobile-app-bar {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
  }

  .app-container {
    flex-direction: column;
  }

  /* Off-canvas mobile drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 85vw);
    height: 100vh;
    z-index: 999;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-close-btn {
    display: flex;
  }

  /* Header becomes vertical flow on mobile */
  .top-header {
    height: auto;
    min-height: auto;
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    position: static;
    background-color: var(--bg-main);
  }

  .header-left {
    justify-content: space-between;
    width: 100%;
  }

  .header-right {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }

  #open-pairing-modal-btn {
    width: 100%;
    min-height: 42px;
  }

  .page-body {
    padding: 16px 12px;
  }

  /* KPI Grid */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 18px;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 18px;
  }

  .card {
    padding: 16px 14px;
  }

  /* Form touch targets on mobile (prevents iOS auto-zoom) */
  .form-input {
    font-size: 16px;
    padding: 10px 12px;
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
  }

  /* Bills filters row stacking */
  .bills-filters-row {
    flex-direction: column;
  }

  #bills-search-input {
    max-width: 100% !important;
    width: 100% !important;
  }

  #bills-status-filter,
  #bills-payment-filter {
    max-width: 100% !important;
    width: 100% !important;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
}

/* Narrow Smart Phones (<= 480px) */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card-header {
    flex-wrap: wrap;
  }

  .donut-chart-flex {
    flex-direction: column !important;
    align-items: center !important;
    height: auto !important;
  }

  .donut-legend {
    margin-left: 0 !important;
    margin-top: 16px !important;
    width: 100% !important;
    max-width: 280px !important;
  }

  .modal-overlay {
    padding: 8px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header, .modal-footer {
    padding: 14px 16px;
  }
}

/* Responsive Branding Safeguards for Narrow Viewports */
@media (max-width: 380px) {
  .mobile-brand {
    gap: 8px;
    max-width: calc(100% - 116px);
  }

  .mobile-brand-logo {
    width: 25px;
    height: 25px;
    border-radius: 6px;
  }

  .mobile-brand-title {
    font-size: 14px;
  }

  .mobile-brand-subtitle {
    font-size: 9px;
    letter-spacing: 0.04em;
  }
}

@media (max-width: 330px) {
  .mobile-app-bar {
    padding: 0 12px;
  }

  .mobile-brand {
    gap: 6px;
    max-width: calc(100% - 100px);
  }

  .mobile-brand-logo {
    width: 22px;
    height: 22px;
    border-radius: 5px;
  }

  .mobile-brand-title {
    font-size: 13px;
  }

  .mobile-brand-subtitle {
    font-size: 8.5px;
    letter-spacing: 0.03em;
  }
}

/* ==========================================================================
   Custom Date Range & Export Report Components
   ========================================================================== */
.active-range-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background-color: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--accent-light);
  font-weight: 600;
  white-space: nowrap;
}

.export-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.export-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background-color: #121a16;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 100;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: slideIn 0.15s ease;
}

.export-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s;
  width: 100%;
  text-decoration: none;
  box-sizing: border-box;
}

.export-menu-item:hover {
  background-color: var(--bg-card-hover);
  color: #fff;
}

.form-error-msg {
  padding: 8px 12px;
  background-color: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12px;
  margin-bottom: 12px;
  line-height: 1.4;
}

@media (max-width: 767px) {
  .export-dropdown-wrapper {
    width: 100%;
  }

  #export-dropdown-btn {
    width: 100%;
    justify-content: center;
  }

  .export-dropdown-menu {
    left: 0;
    right: 0;
    width: 100%;
  }
}
