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

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --sidebar-bg: #ffffff;
  --sidebar-border: #e4ede3;
  --sidebar-text: #6b8a66;
  --sidebar-text-hover: #1a2e18;
  --sidebar-active-bg: #415d3d;
  --sidebar-active-text: #ffffff;
  --sidebar-width: 248px;

  --primary: #415d3d;
  --primary-dark: #2e4229;
  --primary-light: #e8f0e7;
  --primary-mid: #6b9966;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;

  --text-primary: #1a2e18;
  --text-secondary: #4a6647;
  --text-muted: #8aab86;
  --border: #e4ede3;
  --border-hover: #c5d9c2;

  --bg: #f4f7f3;
  --bg-subtle: #f9fbf8;
  --card-bg: #ffffff;
  --input-bg: #f9fbf8;

  --shadow-sm: 0 1px 3px rgba(65,93,61,0.06);
  --shadow: 0 2px 6px rgba(65,93,61,0.08), 0 1px 2px rgba(65,93,61,0.05);
  --shadow-md: 0 4px 12px rgba(65,93,61,0.10), 0 2px 4px rgba(65,93,61,0.06);
  --shadow-lg: 0 12px 24px rgba(65,93,61,0.12), 0 4px 8px rgba(65,93,61,0.06);

  --radius-sm: 5px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Post status */
  --status-draft-bg: #f1f5f9;
  --status-draft-text: #64748b;
  --status-draft-border: #cbd5e1;
  --status-requested-bg: #eef2ff;
  --status-requested-text: #3730a3;
  --status-requested-border: #a5b4fc;
  --status-completed-bg: #d1fae5;
  --status-completed-text: #065f46;
  --status-completed-border: #6ee7b7;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(65,93,61,0.05);
}

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  background: linear-gradient(135deg, #415d3d 0%, #2e4229 100%);
}

.sidebar-logo {
  font-size: 21px;
  font-weight: 800;
  color: rgba(255,255,255,0.9);
  letter-spacing: -0.5px;
}

.sidebar-logo span {
  color: #a8d5a2;
}

.sidebar-tagline {
  font-size: 10.5px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
  font-weight: 400;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 1px 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  position: relative;
}

.sidebar-link:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: 0 2px 8px rgba(65,93,61,0.25);
}

.sidebar-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 15px;
  opacity: 0.85;
}

.sidebar-link.active .sidebar-icon {
  opacity: 1;
}

.sidebar-section-label {
  padding: 14px 24px 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar-user:hover {
  background: var(--primary-light);
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(65,93,61,0.3);
}

.sidebar-username {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

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

.btn-logout {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-logout:hover {
  background: var(--danger-light);
  border-color: #fca5a5;
  color: #b91c1c;
}

/* ── Main Wrapper ────────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
}

/* ── Impersonation Banner ────────────────────────────────────────────────── */
.impersonation-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #415d3d 0%, #2e4229 100%);
  border-bottom: 1px solid #2e4229;
  padding: 10px 28px;
  gap: 12px;
}

.impersonation-banner.visible {
  display: flex;
}

.banner-icon { font-size: 16px; }

.banner-text {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.banner-text strong { color: #a8d5a2; }

.btn-exit-view {
  padding: 5px 14px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-exit-view:hover {
  background: rgba(255,255,255,0.25);
}

/* ── Page Content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-title p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 3px;
}

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

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
  max-width: 100%;
  min-width: 0;
}

.card:hover {
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

/* ── Stats Grid ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -1px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
  line-height: 1;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(65,93,61,0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(65,93,61,0.3);
}

.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--border-hover);
  color: var(--primary-dark);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #fca5a5;
}

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

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px 8px;
}

/* ── Table Controls ──────────────────────────────────────────────────────── */
.table-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

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

.search-box input {
  width: 100%;
  padding: 7px 10px 7px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--card-bg);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(65,93,61,0.12);
}

.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  max-width: 100%;
}

/* Card bodies that contain raw tables also need scroll */
.card-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-subtle);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th[data-sort] {
  cursor: pointer;
  user-select: none;
}

thead th[data-sort]:hover {
  color: var(--primary);
}

thead th.sort-asc::after { content: ' ↑'; }
thead th.sort-desc::after { content: ' ↓'; }

tbody td {
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tbody tr:hover {
  background: var(--primary-light);
}

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

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 44px;
  margin-bottom: 14px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-draft {
  background: var(--status-draft-bg);
  color: var(--status-draft-text);
  border-color: var(--status-draft-border);
}

.badge-requested {
  background: var(--status-requested-bg);
  color: var(--status-requested-text);
  border-color: var(--status-requested-border);
}

.badge-completed {
  background: var(--status-completed-bg);
  color: var(--status-completed-text);
  border-color: var(--status-completed-border);
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: #b5cdb2;
}

.badge-success {
  background: var(--success-light);
  color: #065f46;
  border-color: #6ee7b7;
}

.badge-warning {
  background: var(--warning-light);
  color: #92400e;
  border-color: #fcd34d;
}

.badge-danger {
  background: var(--danger-light);
  color: #991b1b;
  border-color: #fca5a5;
}

.badge-neutral {
  background: #f1f5ef;
  color: #4a6647;
  border-color: #c5d9c2;
}

/* ── Progress Bar ────────────────────────────────────────────────────────── */
.progress-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  flex: 1;
  max-width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-fill.complete {
  background: var(--success);
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="month"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--input-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(65,93,61,0.12);
  background: #fff;
}

input[readonly],
input[disabled] {
  background: #f1f5ef;
  color: var(--text-muted);
  cursor: not-allowed;
}

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b8a66' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,46,24,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.18s ease;
}

.modal-lg {
  max-width: 780px;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Toast Notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  transform: translateX(120%);
  transition: transform 0.25s ease;
  max-width: 340px;
  border-left: 3px solid rgba(255,255,255,0.4);
}

.toast.show {
  transform: translateX(0);
}

.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-info    { background: var(--primary); }
.toast-warning { background: #d97706; }

/* ── Login Page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #e8f0e7 0%, #f4f7f3 40%, #dce8db 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(65,93,61,0.08) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(65,93,61,0.06) 0%, transparent 70%);
  bottom: -80px;
  left: -80px;
  pointer-events: none;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 42px 40px;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
  border-top: 4px solid var(--primary);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
}

.login-logo h1 span {
  color: var(--primary);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.login-error {
  background: var(--danger-light);
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-error.visible { display: block; }

.login-btn {
  width: 100%;
  padding: 11px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(65,93,61,0.25);
}

.login-btn:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(65,93,61,0.35);
}

/* ── Content Post Cards ──────────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}

.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}

.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.post-card.status-draft     { border-left-color: var(--status-draft-border); }
.post-card.status-requested { border-left-color: var(--status-requested-border); }
.post-card.status-completed { border-left-color: var(--status-completed-border); }

.post-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.post-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.post-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.generated-content {
  background: #f4f7f3;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 180px;
  overflow-y: auto;
}

/* ── Reports Page ────────────────────────────────────────────────────────── */
.report-section {
  margin-bottom: 24px;
}

.report-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 0 12px;
}

.due-tag {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Users sub-panel ─────────────────────────────────────────────────────── */
.users-panel {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ── Confirm Dialog ──────────────────────────────────────────────────────── */
.confirm-modal .modal {
  max-width: 420px;
}

.confirm-body {
  padding: 24px 22px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Loading Spinner ─────────────────────────────────────────────────────── */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Tabs (profile modal) ────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Quick Action Cards ──────────────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.quick-action-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  text-decoration: none !important;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.18s;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.quick-action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  text-decoration: none;
}

.qa-icon { font-size: 22px; margin-bottom: 6px; }
.qa-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.qa-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.qa-arrow { font-size: 15px; color: var(--primary); font-weight: 700; margin-top: 8px; }

/* ── Chart Cards ─────────────────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chart-card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
}

.chart-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
}

.chart-card-body {
  padding: 16px;
  position: relative;
  height: 240px;
}

.chart-card-body.tall { height: 300px; }
.chart-card-body.wide { height: 200px; }

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Clickable Table Rows ────────────────────────────────────────────────── */
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link:hover { background: var(--primary-light) !important; }

/* ── Stat Card as Link ───────────────────────────────────────────────────── */
a.stat-card {
  display: block;
  text-decoration: none !important;
  color: inherit;
}

a.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-left-color: var(--primary-dark);
}

.stat-link {
  font-size: 11.5px;
  color: var(--primary);
  font-weight: 600;
  margin-top: 8px;
}

/* ── Mobile Nav Bar (hamburger, hidden on desktop) ───────────────────────── */
.mobile-nav-bar {
  display: none;
}

.hamburger-btn {
  background: none;
  border: none;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
  transition: all 0.2s;
}

.mobile-logo {
  font-size: 18px;
  font-weight: 800;
  color: rgba(255,255,255,0.9);
  letter-spacing: -0.5px;
}

.mobile-logo span { color: #a8d5a2; }

/* Sidebar overlay (mobile only) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
}

.sidebar-overlay.active { display: block; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Show mobile nav bar */
  .mobile-nav-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: linear-gradient(135deg, #415d3d 0%, #2e4229 100%);
    padding: 0 16px;
    z-index: 300;
    box-shadow: 0 2px 8px rgba(65,93,61,0.25);
  }

  /* Sidebar slides in from left */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }

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

  /* Main content shifts down to make room for top bar */
  .main-wrapper {
    margin-left: 0;
    max-width: 100vw;
    padding-top: 52px;
  }

  .main-content { padding: 16px; }

  /* Impersonation banner text wraps better */
  .impersonation-banner {
    padding: 8px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Forms stack vertically */
  .form-row { grid-template-columns: 1fr; }
  .posts-grid { grid-template-columns: 1fr; }

  /* Quick actions: 2 columns */
  .quick-actions { grid-template-columns: 1fr 1fr; }

  /* Stats grid: 2 columns */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Card padding reduce */
  .card-body { padding: 14px; overflow-x: auto; }
  .card-header { padding: 14px 16px; }

  /* Page header stacks */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Modal full-screen on mobile */
  .modal {
    max-width: 100% !important;
    max-height: 95vh;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    align-self: flex-end;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  /* Charts full width */
  .chart-card-body { height: 200px; }
  .chart-card-body.tall { height: 240px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .main-content { padding: 12px; }
  .stat-value { font-size: 26px; }
}

/* ── Client Drawer ──────────────────────────────────────────────────────────── */
.client-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
}
.client-drawer-overlay.open { display: block; }

.client-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 500px;
  max-width: 100vw;
  background: var(--card-bg);
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.client-drawer.open { transform: translateX(0); }

.cd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cd-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cd-tab {
  flex: 1;
  padding: 11px 8px;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
}
.cd-tab:hover { color: var(--text-primary); }
.cd-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.cd-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.cd-panel { display: none; height: 100%; overflow-y: auto; }
.cd-panel.active { display: block; }

.client-name-link {
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
  transition: border-color 0.15s, color 0.15s;
}
.client-name-link:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
