@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

/* Native cross-document view transitions (Chrome 126+). Browsers without
   support simply ignore this rule. */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: pageOut 220ms cubic-bezier(0.2, 0, 0, 1) both;
}
::view-transition-new(root) {
  animation: pageIn 320ms cubic-bezier(0.2, 0, 0, 1) both;
}
@keyframes pageOut {
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

:root {
  /* ===== Brand (kept) ===== */
  --primary-50:  #fff7ed;
  --primary-100: #ffedd5;
  --primary-200: #fed7aa;
  --primary-300: #fdba74;
  --primary-400: #fb923c;
  --primary-500: #f97316;
  --primary-600: #ea580c;
  --primary-700: #c2410c;
  --primary: var(--primary-500);

  /* ===== Neumorphism base ===== */
  --neu-bg:             #e6ebf2;
  --neu-surface:        #e6ebf2;
  --neu-surface-hover:  #ecf0f6;
  --neu-light:          rgba(255, 255, 255, 0.95);
  --neu-dark:           rgba(163, 177, 198, 0.48);
  --neu-darker:         rgba(163, 177, 198, 0.72);

  --text:        #2b3a4b;
  --text-muted:  #64748b;
  --text-subtle: #94a3b8;
  --border:      rgba(163, 177, 198, 0.22);

  /* Back-compat aliases (older rules reference these) */
  --surface:       var(--neu-bg);
  --surface-2:     var(--neu-surface-hover);
  --border-strong: rgba(163, 177, 198, 0.4);
  --text-dark:     var(--text);
  --primary-dark:  var(--primary-600);
  --bg-cream:      var(--primary-50);
  --bg:            var(--neu-bg);
  --gold:          #d97706;
  --teal:          #0d9488;
  --slate-50:      #f1f5f9;
  --slate-100:     #e9eef5;
  --slate-200:     #dbe1ea;
  --slate-600:     #475569;

  /* ===== Neumorphic shadow kits ===== */
  --neu-raised:     -7px -7px 14px var(--neu-light), 7px 7px 14px var(--neu-dark);
  --neu-raised-lg: -11px -11px 24px var(--neu-light), 11px 11px 24px var(--neu-dark);
  --neu-raised-sm:  -3px -3px 6px var(--neu-light), 3px 3px 6px var(--neu-dark);
  --neu-raised-xs:  -2px -2px 4px var(--neu-light), 2px 2px 4px var(--neu-dark);
  --neu-inset:      inset 3px 3px 6px var(--neu-dark), inset -3px -3px 6px var(--neu-light);
  --neu-inset-sm:   inset 2px 2px 4px var(--neu-dark), inset -2px -2px 4px var(--neu-light);
  --neu-inset-lg:   inset 5px 5px 10px var(--neu-dark), inset -5px -5px 10px var(--neu-light);
  --neu-pressed:    inset 4px 4px 8px var(--neu-darker), inset -4px -4px 8px var(--neu-light);

  /* Back-compat shadow aliases */
  --shadow-xs: var(--neu-raised-xs);
  --shadow-sm: var(--neu-raised-sm);
  --shadow-md: var(--neu-raised);
  --shadow-lg: var(--neu-raised-lg);
  --shadow-xl: var(--neu-raised-lg);
  --shadow-primary: 0 10px 22px -8px rgba(249, 115, 22, 0.45);
  --ring-primary:   0 0 0 3px rgba(249, 115, 22, 0.25);
  --ring-danger:    0 0 0 3px rgba(220, 38, 38, 0.2);

  /* ===== Semantic (for badges/alerts that stay colored) ===== */
  --success-50: #f0fdf4; --success-600: #16a34a; --success-700: #15803d;
  --warning-50: #fffbeb; --warning-600: #d97706; --warning-700: #b45309;
  --danger-50:  #fef2f2; --danger-600:  #dc2626; --danger-700:  #b91c1c;
  --info-50:    #eff6ff; --info-600:    #2563eb;

  /* ===== Radii (softer) ===== */
  --r-xs: 6px;
  --r-sm: 10px;
  --r:    14px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* ===== Motion ===== */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t-fast: 140ms var(--ease);
  --t: 220ms var(--ease);
}

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

html, body {
  font-family: 'Cairo', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--neu-bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* No grid/dot pattern — neumorphism needs a flat base */
body.has-sidebar { background: var(--neu-bg); }

/* ===== Thin, translucent "floating" scrollbars ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  background: transparent;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background var(--t-fast);
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.65);
  background-clip: padding-box;
  border: 2px solid transparent;
}
*::-webkit-scrollbar-corner { background: transparent; }

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

.contracts-table td,
.contracts-table th,
.totals-strip .value,
.mini-value,
.event-card-head .date-range {
  font-variant-numeric: tabular-nums;
}

/* ===== Top navigation progress bar (fallback for browsers without @view-transition) ===== */
#nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  z-index: 9998;
  pointer-events: none;
}
#nav-progress::after {
  content: '';
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.6);
  transition: width 300ms cubic-bezier(0.2, 0, 0, 1);
  border-radius: 0 2px 2px 0;
}
#nav-progress.loading::after { width: 70%; transition-duration: 1400ms; }
#nav-progress.done::after    { width: 100%; transition-duration: 140ms; }

/* Page fade-in on load (fallback when @view-transition isn't supported) */
@media (prefers-reduced-motion: no-preference) {
  .page-main {
    animation: fadeUp 280ms cubic-bezier(0.2, 0, 0, 1) both;
  }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Layout ===== */
.page-main { max-width: 1200px; margin: 0 auto; padding: 32px; }
body.has-sidebar .page-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 52px;
  width: 100%;
}

/* ===== Sidebar toggle button (always visible) ===== */
.sidebar-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--neu-bg);
  box-shadow: var(--neu-raised-sm);
  border: none;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow var(--t-fast), color var(--t-fast);
}
.sidebar-toggle:hover  { color: var(--primary-600); box-shadow: var(--neu-raised); }
.sidebar-toggle:active { box-shadow: var(--neu-inset-sm); }
.sidebar-toggle .icon-close { display: none; }
body.sidebar-open .sidebar-toggle .icon-open  { display: none; }
body.sidebar-open .sidebar-toggle .icon-close { display: block; }

/* Sidebar backdrop (mobile only, when open) */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 58, 75, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 49;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease);
}
body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ===== Sidebar (raised neumorphic slab) ===== */
body.has-sidebar {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
  gap: 24px;
  padding: 24px 24px 24px 0;
  transition: grid-template-columns var(--t);
}

/* Desktop collapsed state — hide the sidebar column entirely */
@media (min-width: 901px) {
  body.has-sidebar.sidebar-hidden {
    grid-template-columns: 1fr;
    padding: 24px;
  }
  body.has-sidebar.sidebar-hidden .sidebar {
    display: none;
  }
}

.sidebar {
  background: var(--neu-bg);
  padding: 52px 14px 18px;   /* extra top padding to clear the toggle button */
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  overflow-y: auto;
  border-radius: var(--r-xl);
  box-shadow: var(--neu-raised-lg);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  color: var(--text);
  font-size: 14px;
  padding: 6px 12px 18px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.sidebar-brand::before {
  content: '';
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  box-shadow: var(--neu-raised-sm), 0 6px 12px -4px rgba(249, 115, 22, 0.45);
  flex-shrink: 0;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-subtle);
  letter-spacing: 0.1em;
  padding: 6px 14px 4px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--r);
  font-weight: 500;
  font-size: 13px;
  transition: box-shadow var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
  transition: stroke-width var(--t-fast);
}
.sidebar-nav a:hover {
  color: var(--text);
  box-shadow: var(--neu-raised-xs);
}
.sidebar-nav a.active {
  color: var(--primary-700);
  font-weight: 700;
  box-shadow: var(--neu-inset);
}
.sidebar-nav a.active svg { stroke-width: 2.2; }
.sidebar-nav a.active span { font-weight: 700; }

/* Overdue badge in sidebar */
.badge-alert {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--danger-600);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  margin-right: auto;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
  animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4); }
  50%      { box-shadow: 0 2px 12px rgba(220, 38, 38, 0.7); }
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: var(--neu-raised-sm), 0 4px 10px -3px rgba(249, 115, 22, 0.4);
}
.sidebar-user .who { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.sidebar-user .who-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user .who-role { font-size: 11px; color: var(--text-muted); }
.sidebar-foot .btn-ghost {
  width: 100%;
  justify-content: center;
  padding: 9px 12px;
  font-size: 12px;
}

/* ===== Typography ===== */
h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.2;
}
h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}
h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.muted { color: var(--text-muted); font-size: 13px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  gap: 16px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: 6px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-subtle);
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 500;
  transition: color var(--t-fast);
}
.back-link:hover { color: var(--primary-600); }

/* ===== Buttons ===== */
.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: box-shadow var(--t-fast), transform var(--t-fast), color var(--t-fast);
  border: none;
  line-height: 1;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: #fff;
  box-shadow: var(--neu-raised-sm), 0 10px 22px -8px rgba(249, 115, 22, 0.45);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--neu-raised), 0 14px 26px -8px rgba(249, 115, 22, 0.5);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--neu-pressed), 0 4px 10px -4px rgba(249, 115, 22, 0.35);
}

.btn-ghost {
  background: var(--neu-bg);
  color: var(--text);
  box-shadow: var(--neu-raised-sm);
}
.btn-ghost:hover {
  box-shadow: var(--neu-raised);
  color: var(--text);
}
.btn-ghost:active {
  box-shadow: var(--neu-inset);
}

.btn-primary:focus-visible,
.btn-ghost:focus-visible {
  outline: none;
  box-shadow: var(--neu-raised-sm), var(--ring-primary);
}

/* ===== Dashboard / Overview ===== */
.dashboard h1 { margin-bottom: 4px; }
.dashboard > .page-header { margin-bottom: 26px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 16px;
}
.section-head h2 { font-size: 14px; font-weight: 700; color: var(--text); }
.section-head .muted { font-size: 12px; }

.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
}
@media (min-width: 1200px) {
  .event-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
}

.event-card {
  background: var(--neu-bg);
  padding: 24px 26px;
  border-radius: var(--r-lg);
  box-shadow: var(--neu-raised);
  color: inherit;
  transition: transform var(--t), box-shadow var(--t);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
}
.event-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--neu-raised-lg);
}

.event-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.event-card-head h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.event-card-head .date-range {
  font-size: 11.5px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.event-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 18px;
  border-radius: var(--r);
  box-shadow: var(--neu-inset);
  background: var(--neu-bg);
}
.mini-stat { display: flex; flex-direction: column; gap: 3px; }
.mini-stat .mini-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.mini-stat .mini-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.mini-stat .mini-sub { font-size: 9.5px; color: var(--text-subtle); }

.event-card-bar { display: flex; flex-direction: column; gap: 8px; }
.bar-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
}
.bar-label { color: var(--text-muted); font-weight: 500; }
.bar-val { color: var(--text); font-weight: 700; }
.progress {
  height: 10px;
  background: var(--neu-bg);
  border-radius: var(--r-full);
  overflow: hidden;
  box-shadow: var(--neu-inset-sm);
  padding: 2px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
  border-radius: var(--r-full);
  transition: width 400ms var(--ease);
  box-shadow: 0 1px 3px rgba(249, 115, 22, 0.5);
}

.alert-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--warning-700);
  background: var(--warning-50);
  padding: 10px 14px;
  border-radius: var(--r);
  box-shadow: var(--neu-raised-xs), inset 0 0 0 1px #fde68a;
}
.alert-line svg { flex-shrink: 0; }

.event-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.event-card-actions .btn-primary,
.event-card-actions .btn-ghost {
  flex: 1;
  justify-content: center;
  font-size: 12px;
  padding: 9px 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--primary-50);
  color: var(--primary-700);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--neu-raised-xs);
}

/* ===== Tables ===== */
.contracts-table {
  width: 100%;
  background: var(--neu-bg);
  border-radius: var(--r-lg);
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: var(--neu-raised);
  font-size: 13px;
}
.contracts-table th,
.contracts-table td {
  padding: 15px 20px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.contracts-table thead th {
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.contracts-table tbody tr {
  transition: background var(--t-fast);
}
.contracts-table tbody tr:hover { background: var(--neu-surface-hover); }
.contracts-table tbody tr:last-child td { border-bottom: none; }
.contracts-table code {
  background: var(--neu-bg);
  padding: 4px 10px;
  border-radius: var(--r-xs);
  font-size: 11.5px;
  font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace;
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--neu-inset-sm);
}
.contracts-table a { color: var(--text); }
.contracts-table a:hover { color: var(--primary-600); }

.contracts-table input[type="date"],
.contracts-table input[type="text"],
.contracts-table input[type="number"],
.contracts-table select {
  padding: 9px 12px;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 12.5px;
  background: var(--neu-bg);
  color: var(--text);
  width: 100%;
  box-shadow: var(--neu-inset-sm);
  transition: box-shadow var(--t-fast);
}
.contracts-table input:focus,
.contracts-table select:focus {
  outline: 2px solid var(--primary-400);
  outline-offset: 2px;
  box-shadow: var(--neu-inset-sm), var(--ring-primary);
}

/* ===== Status badges (kept colorful for clarity) ===== */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
  box-shadow: var(--neu-raised-xs);
}
.status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  opacity: 0.85;
}
.status-draft      { background: #fef3c7; color: #92400e; }
.status-active     { background: #dcfce7; color: #166534; }
.status-cancelled  { background: #fee2e2; color: #991b1b; }
.status-completed  { background: #dbeafe; color: #1e40af; }
.status-overdue    { background: #fee2e2; color: #b91c1c; }
.status-duesoon    { background: #ffedd5; color: #9a3412; }
.status-scheduled  { background: #e0f2fe; color: #075985; }
.status-nodate     { background: var(--neu-bg); color: var(--slate-600); box-shadow: var(--neu-inset-sm); }
.status-paid       { background: #dcfce7; color: #166534; }
.status-booth-available { background: #dcfce7; color: #166534; }
.status-booth-reserved  { background: #fef3c7; color: #92400e; }
.status-booth-rented    { background: #dbeafe; color: #1e40af; }
.status-booth-blocked   { background: #fee2e2; color: #991b1b; }

/* ===== Totals strip ===== */
.totals-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin: 22px 0 30px;
}
.totals-strip .stat {
  background: var(--neu-bg);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  box-shadow: var(--neu-raised);
  position: relative;
  transition: transform var(--t), box-shadow var(--t);
}
.totals-strip .stat:hover {
  transform: translateY(-1px);
  box-shadow: var(--neu-raised-lg);
}
.totals-strip .stat::before {
  content: '';
  position: absolute;
  top: 22px;
  left: 22px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--neu-bg);
  box-shadow: var(--neu-inset-sm);
}
.totals-strip .stat::after {
  content: '';
  position: absolute;
  top: 27px;
  left: 27px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-subtle);
  box-shadow: 0 0 6px currentColor;
}
.totals-strip .stat.outstanding::after { background: var(--danger-600); }
.totals-strip .stat.paid::after        { background: var(--success-600); }
.totals-strip .stat.total::after       { background: var(--primary-500); }

.totals-strip .stat .label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.totals-strip .stat .value {
  font-size: 24px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

/* ===== Table horizontal-scroll wrapper ===== */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--neu-raised);
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.table-scroll > .contracts-table {
  box-shadow: none;
  border-radius: 0;
  margin-bottom: 0;
  min-width: 100%;
  width: max-content;
}

/* ===== Table tools bar (search + count) ===== */
.table-tools-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.table-search {
  flex: 1;
  min-width: 180px;
  padding: 11px 16px;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13.5px;
  background: var(--neu-bg);
  color: var(--text);
  box-shadow: var(--neu-inset);
  transition: box-shadow var(--t-fast);
}
.table-search:focus {
  outline: none;
  box-shadow: var(--neu-inset), var(--ring-primary);
}
.table-search::placeholder {
  color: var(--text-subtle);
}
.table-count {
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Sort arrows in headers */
.sort-arrow {
  font-size: 11px;
  color: var(--text-subtle);
  margin-right: 2px;
}
.sort-arrow.active {
  color: var(--primary-600);
}
th[data-sort] {
  transition: color var(--t-fast);
}
th[data-sort]:hover {
  color: var(--primary-600);
}

/* ===== Filter row (used on list pages with dropdown filters) ===== */
.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-row select,
.filter-row input[type="text"] {
  padding: 10px 14px;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  background: var(--neu-bg);
  color: var(--text);
  box-shadow: var(--neu-inset-sm);
  min-width: 160px;
}
.filter-row select:focus,
.filter-row input:focus {
  outline: 2px solid var(--primary-400);
  outline-offset: 2px;
  box-shadow: var(--neu-inset-sm), var(--ring-primary);
}

/* ===== Danger button variant ===== */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: #fef2f2;
  color: var(--danger-700);
  box-shadow: var(--neu-raised-sm);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.btn-danger:hover { box-shadow: var(--neu-raised); }
.btn-danger:active { box-shadow: var(--neu-inset); transform: translateY(0); }

/* ===== Empty state ===== */
.empty-state {
  background: var(--neu-bg);
  padding: 64px 24px;
  text-align: center;
  color: var(--text-muted);
  border-radius: var(--r-lg);
  box-shadow: var(--neu-inset);
  font-size: 13.5px;
  font-weight: 500;
}

/* ===== Small buttons ===== */
.btn-sm {
  padding: 7px 14px;
  font-size: 11.5px;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.btn-sm:active { transform: scale(0.97); }
.btn-sm-pay {
  background: #dcfce7;
  color: #166534;
  box-shadow: var(--neu-raised-sm);
}
.btn-sm-pay:hover  { box-shadow: var(--neu-raised); }
.btn-sm-pay:active { box-shadow: var(--neu-inset-sm); }
.btn-sm-unpay {
  background: #fef3c7;
  color: #92400e;
  box-shadow: var(--neu-raised-sm);
}
.btn-sm-unpay:hover  { box-shadow: var(--neu-raised); }
.btn-sm-unpay:active { box-shadow: var(--neu-inset-sm); }

/* ===== Login (split-screen) ===== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--neu-bg);
}
@media (min-width: 900px) {
  .login-wrap { grid-template-columns: 1fr 1.1fr; }
}

.login-hero {
  display: none;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-500) 40%, #fb923c 100%);
  color: #fff;
  padding: 64px 56px;
  position: relative;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
}
@media (min-width: 900px) { .login-hero { display: flex; } }
.login-hero::before,
.login-hero::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}
.login-hero::before {
  width: 440px; height: 440px;
  background: rgba(255, 255, 255, 0.2);
  top: -110px; left: -120px;
}
.login-hero::after {
  width: 340px; height: 340px;
  background: rgba(255, 255, 255, 0.14);
  bottom: -100px; right: -70px;
}
.login-hero .hero-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 16px;
  position: relative;
  z-index: 1;
}
.login-hero .hero-brand .hero-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.login-hero .hero-title {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
  max-width: 460px;
}
.login-hero .hero-sub {
  font-size: 15px;
  opacity: 0.9;
  line-height: 1.7;
  max-width: 460px;
  position: relative;
  z-index: 1;
}
.login-hero .hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  z-index: 1;
}
.login-hero .hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px);
}

.login-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.login-card {
  background: var(--neu-bg);
  padding: 48px 50px;
  border-radius: var(--r-xl);
  box-shadow: var(--neu-raised-lg);
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 420ms var(--ease);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-card h1 { font-size: 26px; margin-bottom: 2px; }
.login-card > .muted { margin-bottom: 12px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.login-card input {
  padding: 13px 16px;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--neu-bg);
  color: var(--text);
  box-shadow: var(--neu-inset);
  transition: box-shadow var(--t-fast);
}
.login-card input:focus {
  outline: none;
  box-shadow: var(--neu-inset), var(--ring-primary);
}
.login-card .btn-primary {
  margin-top: 8px;
  padding: 14px 22px;
  font-size: 14px;
}
.error-banner {
  background: var(--danger-50);
  color: var(--danger-700);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  box-shadow: var(--neu-raised-xs), inset 0 0 0 1px #fecaca;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Toast notifications ===== */
#toast-container {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 440px;
  padding: 13px 18px;
  background: var(--neu-bg);
  color: var(--text);
  border-radius: var(--r);
  box-shadow: var(--neu-raised-lg);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 11px;
  animation: toastIn 260ms var(--ease);
  border-left: 3px solid var(--text-subtle);
}
.toast.success { border-left-color: var(--success-600); }
.toast.error { border-left-color: var(--danger-600); }
.toast.info { border-left-color: var(--info-600); }
.toast .toast-icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success-600); }
.toast.error .toast-icon { color: var(--danger-600); }
.toast.info .toast-icon { color: var(--info-600); }
.toast.out { animation: toastOut 220ms var(--ease) forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ===== Mobile ===== */
@media (max-width: 900px) {
  body.has-sidebar {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }
  .sidebar {
    position: fixed;
    top: 16px;
    right: 16px;
    bottom: 16px;
    width: 260px;
    max-width: calc(100vw - 32px);
    z-index: 50;
    transform: translateX(calc(100% + 32px));
    transition: transform 280ms var(--ease);
    padding: 52px 14px 16px;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .page-main { padding: 76px 16px 20px; }
  body.has-sidebar .page-main { padding: 76px 16px 20px; }
  h1 { font-size: 20px; }

  /* Hamburger button positioned for mobile — right side */
  .sidebar-toggle { top: 16px; right: 16px; }

  /* Page header: stack title above actions */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 20px;
  }
  .page-header .btn-primary,
  .page-header .btn-ghost,
  .page-header > a.btn-primary,
  .page-header > a.btn-ghost {
    width: 100%;
    justify-content: center;
  }

  /* Tables: smaller padding + font */
  .contracts-table th,
  .contracts-table td {
    padding: 10px 12px;
    font-size: 12px;
  }
  .contracts-table thead th {
    font-size: 10px;
    padding: 10px 12px;
  }
  .contracts-table code {
    padding: 2px 7px;
    font-size: 10.5px;
  }
  .contracts-table .btn-ghost {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Filter rows stack */
  .filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-row select,
  .filter-row input[type="text"] {
    width: 100%;
    min-width: 0;
  }
  .filter-row .btn-ghost {
    width: 100%;
    justify-content: center;
  }

  /* Totals strip sizing */
  .totals-strip {
    gap: 12px;
    margin: 16px 0 22px;
  }
  .totals-strip .stat {
    padding: 16px 18px;
  }
  .totals-strip .stat .value { font-size: 20px; }

  /* ===== Card-mode tables (permits, entry-cards, contract-payments) ===== */
  .contracts-table[data-cards] {
    display: block;
    box-shadow: none;
    border: none;
    background: transparent;
    width: 100%;
    min-width: 0;
  }
  .contracts-table[data-cards] thead { display: none; }
  .contracts-table[data-cards] tbody { display: block; }
  .contracts-table[data-cards] tbody tr {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 14px;
    padding: 14px 16px;
    border-radius: var(--r);
    box-shadow: var(--neu-raised-sm);
    background: var(--neu-bg);
    transition: none;
  }
  .contracts-table[data-cards] tbody tr:hover { background: var(--neu-bg); }
  .contracts-table[data-cards] tbody tr:last-child { margin-bottom: 0; }
  .contracts-table[data-cards] td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    width: 100%;
    min-width: 0;
  }
  .contracts-table[data-cards] td:last-child { border-bottom: none; }
  .contracts-table[data-cards] td[data-label]::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
    letter-spacing: 0.02em;
  }
  .contracts-table[data-cards] td[data-label=""]::before { display: none; }
  .contracts-table[data-cards] td:not([data-label]) {
    justify-content: stretch;
  }
  .contracts-table[data-cards] td input,
  .contracts-table[data-cards] td select {
    flex: 1 1 auto;
    max-width: 62%;
    min-width: 0;
  }
  .contracts-table[data-cards] td[data-label=""] .btn-sm,
  .contracts-table[data-cards] td[data-label=""] .btn-ghost,
  .contracts-table[data-cards] td[data-label=""] .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

/* ===== Narrow mobile (<=600px): 2-col totals strip ===== */
@media (max-width: 600px) {
  .totals-strip {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .totals-strip .stat { padding: 14px 16px; }
  .totals-strip .stat .value { font-size: 18px; }
  .totals-strip .stat .label { font-size: 10.5px; }
  .totals-strip .stat::before { top: 14px; left: 16px; width: 11px; height: 11px; }
  .totals-strip .stat::after { top: 17px; left: 19px; }
}

/* ===== Print ===== */
@media print {
  .no-print, .sidebar, .sidebar-toggle, .sidebar-backdrop, #toast-container { display: none !important; }
  body.has-sidebar {
    display: block;
    background: #fff;
    padding: 0;
  }
  body { background: #fff; }
  .page-main, body.has-sidebar .page-main { max-width: none; padding: 0 !important; }
  .contract-container, .page { box-shadow: none !important; }
}
