/* ========================================
   CSS Variables & Theme — .exd inspired
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Zalando+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #e63964;
  --primary-dark: #c92d54;
  --primary-light: rgba(230,57,100,0.08);
  --secondary: #6b7280;
  --accent: #e63964;

  --bg: #f5f5fa;
  --bg-page: #f0f0f7;
  --bg-card: rgba(255,255,255,0.75);
  --bg-card-solid: #ffffff;
  --bg-input: #ffffff;
  --bg-sidebar: #1a1b4b;
  --bg-sidebar-hover: rgba(255,255,255,0.08);
  --bg-sidebar-active: var(--primary);

  --text: #1a1b3d;
  --text-light: #6b7280;
  --text-sidebar: #c0c2d0;

  --border: rgba(0,0,0,0.08);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --success-bg: rgba(16,185,129,0.1);
  --warning-bg: rgba(245,158,11,0.1);
  --danger-bg: rgba(239,68,68,0.1);

  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --font: 'Zalando Sans', system-ui, -apple-system, sans-serif;

  --gradient: linear-gradient(135deg, #1a1b4b 0%, #2d1b69 40%, #7b2d5f 70%, #c9395a 100%);
  --gradient-accent: linear-gradient(135deg, #e63964, #d946a8);
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Animated background blob — single gradient blob, blue-to-coral */
body::before {
  content: '';
  position: fixed;
  width: 120vw;
  height: 120vh;
  top: -30vh;
  left: -30vw;
  background: radial-gradient(
    ellipse at 30% 50%,
    rgba(26,27,75,0.35) 0%,
    rgba(75,35,130,0.3) 25%,
    rgba(180,50,100,0.25) 50%,
    rgba(230,57,100,0.15) 70%,
    transparent 85%
  );
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  animation: blobDrift 30s ease-in-out infinite;
}

@keyframes blobDrift {
  0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
  33% { transform: translate(5vw, 3vh) scale(1.05) rotate(3deg); }
  66% { transform: translate(-3vw, -2vh) scale(0.97) rotate(-2deg); }
}

/* All real content above blobs */
.app-layout, .login-wrapper, #freelancer-view, #manager-view,
.toast-container, .modal-overlay {
  position: relative;
  z-index: 1;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }

/* ========================================
   Login Page
   ======================================== */
html.login-html {
  height: var(--app-height, 100vh);
  height: 100dvh;
  overflow: hidden;
}

.login-body {
  height: var(--app-height, 100vh);
  height: 100dvh;
  overflow: hidden;
  margin: 0;
  /* Prevent overscroll/bounce on iOS */
  overscroll-behavior: none;
}

/* Hide blobs on login page — they cause horizontal overflow */
.login-body::before { display: none !important; }

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--app-height, 100vh);
  height: 100dvh;
  background: var(--gradient);
  padding: 1rem;
  overflow: hidden;
}


.login-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.login-card .form-group label { color: #4b5563; }
.login-card .form-control { border-color: rgba(0,0,0,0.12); }

.login-card .logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-card .logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card .logo p {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 16px; /* prevents iOS zoom on focus */
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230,57,100,0.15);
}

.form-control::placeholder { color: #9ca3af; }

/* Calendar/date picker icon */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none;
}

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b8fa3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group { flex: 1; }

.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.3rem;
  font-size: 0.9rem;
  font-family: var(--font);
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(230,57,100,0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(230,57,100,0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255,255,255,0.8);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,1); }

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

.btn-success {
  background: var(--success);
  color: #0f1035;
  font-weight: 700;
}
.btn-success:hover { background: #2dd38d; }

.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
}

.btn-block { width: 100%; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 50%;
  color: var(--text-light);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: rgba(0,0,0,0.05); color: var(--text); }

/* ========================================
   Layout: Sidebar + Topbar
   ======================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h2 {
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--text-light);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  border-radius: 0;
}

.nav-item:hover { background: var(--bg-sidebar-hover); text-decoration: none; }
.nav-item.active {
  background: var(--bg-sidebar-active);
  color: #fff;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: currentColor;
}

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

.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-left h1 { font-size: 1.2rem; font-weight: 700; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  color: var(--text);
}

.menu-toggle svg { width: 24px; height: 24px; fill: currentColor; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-user {
  font-size: 0.9rem;
  color: var(--text-light);
}

.topbar-user strong {
  color: var(--text);
  font-weight: 500;
}

.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
}

/* ========================================
   Cards
   ======================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
}

.card-header h2 { margin: 0; }
.card-header h3 { margin: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.fl-pill-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #fff;
  border-radius: 999px;
  padding: 0.35rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 14px rgba(26, 27, 75, 0.08);
  border: 1px solid rgba(26, 27, 75, 0.06);
}

.fl-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.6rem 0.4rem 1.1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 14px rgba(26, 27, 75, 0.08);
  border: 1px solid rgba(26, 27, 75, 0.06);
}

.fl-topbar-left,
.fl-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fl-topbar-center {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.fl-topbar-user {
  background: transparent;
  border: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.fl-topbar-user:hover {
  background: rgba(26, 27, 75, 0.06);
}

.fl-topbar-icon {
  background: transparent;
  border: 0;
  padding: 0.4rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.fl-topbar-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.fl-topbar-icon:hover {
  background: rgba(26, 27, 75, 0.06);
  color: var(--text);
}

@media (max-width: 640px) {
  /* Keep desktop-style horizontal layout: logo left, user + icons right */
  .fl-topbar {
    flex-wrap: nowrap;
    border-radius: 999px;
    padding: 0.35rem 0.5rem 0.35rem 0.85rem;
    gap: 0.5rem;
  }
  .fl-topbar-left {
    flex-shrink: 0;
  }
  .fl-topbar-right {
    gap: 0.3rem;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .fl-topbar-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

.fl-pill-tab {
  border: 0;
  background: transparent;
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-light);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.fl-pill-tab:hover {
  color: var(--text);
}

.fl-pill-tab.active {
  background: rgba(230, 57, 100, 0.1);
  color: var(--primary);
  box-shadow: none;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 0.25rem;
}

.stat-card .stat-sub {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.15rem;
}

/* ========================================
   Tables
   ======================================== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  /* min-width:0 prevents the wrap from growing past its parent in a flex/grid context */
  min-width: 0;
  max-width: 100%;
}

/* Card has block layout by default; ensure children can't push it wider */
.card {
  min-width: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.7rem 0.75rem;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: rgba(0,0,0,0.02); }
tbody tr:last-child td { border-bottom: none; }

.table-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

/* ========================================
   Progress Bars (Budget)
   ======================================== */
.progress-wrap {
  margin: 0.35rem 0;
}

.progress-bar {
  height: 8px;
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-fill.green { background: var(--success); box-shadow: 0 0 8px rgba(16,185,129,0.3); }
.progress-fill.yellow { background: var(--warning); box-shadow: 0 0 8px rgba(245,158,11,0.3); }
.progress-fill.red { background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,0.3); }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 0.2rem;
}

/* ========================================
   Badges & Tags
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 50px;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-secondary { background: rgba(0,0,0,0.05); color: var(--text-light); }

.role-badge { text-transform: capitalize; }

/* ========================================
   Modals
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-header h2 { font-size: 1.15rem; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  color: var(--text-light);
  font-size: 1.5rem;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 1.25rem;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  pointer-events: auto;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--primary);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-error   { border-left-color: var(--danger); }

.toast-body { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.9rem; }
.toast-message { font-size: 0.83rem; color: var(--text-light); margin-top: 0.1rem; }

.toast-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ========================================
   Section visibility
   ======================================== */
.section { display: none; }
.section.active { display: block; }

/* ========================================
   Empty state
   ======================================== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  fill: var(--border);
  margin-bottom: 1rem;
}

.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }

/* ========================================
   Confirmation dialog
   ======================================== */
.confirm-text {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ========================================
   Misc Utilities
   ======================================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 0.83rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: 0.5rem; }

.hidden { display: none !important; }

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(0,0,0,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.loading-box .loading-spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

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

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .login-card {
    padding: 1.75rem 1.5rem;
  }

  .login-card .logo { margin-bottom: 1.25rem; }
  .login-card .form-group { margin-bottom: 1rem; }

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

  .main-area {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .content {
    padding: 1rem;
  }

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

  .stat-cards {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .topbar-user span { display: none; }

  .modal {
    max-width: 100%;
    margin: 0.5rem;
  }

  table { font-size: 0.82rem; }
  thead th, tbody td { padding: 0.5rem; }
}

@media (max-width: 480px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   Freelancer/manager compact view
   ======================================== */
.fl-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

@media (max-width: 640px) {
  .fl-content {
    padding: 1rem 0.75rem;
  }
  .fl-topbar {
    margin-bottom: 1rem;
  }
  .fl-topbar-user {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
  }
  .fl-topbar-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }
  .fl-topbar-icon svg {
    width: 16px;
    height: 16px;
  }
  /* Form grid in the freelancer log form (Cliente / Progetto / Attività) */
  #single-log-form > div:first-of-type {
    grid-template-columns: 1fr !important;
  }
  /* Cards: tighter padding */
  .card {
    padding: 1rem;
  }
  .card-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  /* Tables: smaller text + tighter cells; outer .table-wrap already scrolls */
  .table-wrap {
    margin: 0;
  }
  .table-wrap table {
    font-size: 0.82rem;
  }
  .table-wrap th,
  .table-wrap td {
    padding: 0.55rem 0.5rem;
  }
  /* Buttons inside small viewports: don't shrink labels */
  .btn-sm {
    white-space: nowrap;
  }
  /* Modal dialogs: edge-to-edge with small inset */
  .modal-overlay .modal {
    margin: 0.75rem;
    max-width: calc(100% - 1.5rem);
  }
  /* Dialog (confirm/prompt) stretching */
  .modal-overlay .modal[style*="max-width:440px"] {
    max-width: calc(100% - 1.5rem) !important;
  }
}

@media (max-width: 480px) {
  .fl-content {
    padding: 0.75rem 0.5rem;
  }
  .fl-topbar {
    padding: 0.3rem 0.4rem 0.3rem 0.7rem;
    gap: 0.3rem;
  }
  .fl-topbar-user {
    max-width: 90px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
  }
  .fl-topbar-icon {
    width: 32px;
    height: 32px;
  }
  .fl-topbar-icon svg {
    width: 15px;
    height: 15px;
  }
  /* Tighter table cells on the smallest screens */
  .table-wrap th,
  .table-wrap td {
    padding: 0.45rem 0.4rem;
  }
}
