:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f3f6fb;
  --surface-3: #edf2f7;
  --text: #0f172a;
  --text-strong: #0b1220;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #635bff;
  --primary-strong: #4f46e5;
  --primary-soft: rgba(99, 91, 255, .10);
  --success: #047857;
  --success-soft: #d1fae5;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --sidebar-w: 224px;
  --topbar-h: 62px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .04);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1020;
    --surface: #111827;
    --surface-2: #172033;
    --surface-3: #1f2937;
    --text: #e5edf8;
    --text-strong: #f8fafc;
    --muted: #9aa7ba;
    --muted-2: #6b778b;
    --border: #263245;
    --border-strong: #3a485e;
    --primary: #8b7dff;
    --primary-strong: #a99fff;
    --primary-soft: rgba(139, 125, 255, .16);
    --success: #34d399;
    --success-soft: rgba(16, 185, 129, .14);
    --warning: #fbbf24;
    --warning-soft: rgba(245, 158, 11, .16);
    --danger: #f87171;
    --danger-soft: rgba(239, 68, 68, .16);
    --info: #60a5fa;
    --info-soft: rgba(59, 130, 246, .15);
    --shadow: 0 1px 2px rgba(0,0,0,.24), 0 10px 26px rgba(0,0,0,.18);
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #111827;
  --surface-2: #172033;
  --surface-3: #1f2937;
  --text: #e5edf8;
  --text-strong: #f8fafc;
  --muted: #9aa7ba;
  --muted-2: #6b778b;
  --border: #263245;
  --border-strong: #3a485e;
  --primary: #8b7dff;
  --primary-strong: #a99fff;
  --primary-soft: rgba(139, 125, 255, .16);
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, .14);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, .16);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, .16);
  --info: #60a5fa;
  --info-soft: rgba(59, 130, 246, .15);
  --shadow: 0 1px 2px rgba(0,0,0,.24), 0 10px 26px rgba(0,0,0,.18);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary-strong); }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1100;
  display: flex;
  flex-direction: column;
}
.sidebar-head {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 0 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-org {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-weight: 700;
  text-decoration: none;
  min-width: 0;
}
.sidebar-org-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--primary-strong);
  font-size: 12px;
  flex: none;
}
.sidebar-org-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-close { display: none; }
.sidebar-nav { padding: 12px 10px 18px; overflow: auto; }
.sidebar-section { margin: 8px 0; }
.sidebar-section-toggle {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 9px;
  text-transform: none;
  font-weight: 650;
  font-size: 13px;
}
.sidebar-section-toggle:hover { background: var(--surface-2); color: var(--text); }
.sidebar-section .chev { transition: transform .16s ease; }
.sidebar-section:not(.open) .chev { transform: rotate(-90deg); }
.sidebar-section:not(.open) .sidebar-section-items { display: none; }
.sidebar-section-items { padding: 2px 0 3px; }
.sidebar-link {
  min-height: 34px;
  display: flex;
  align-items: center;
  border-radius: 9px;
  padding: 7px 10px 7px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  margin: 1px 0;
  border: 1px solid transparent;
}
.sidebar-link.top { padding-left: 10px; font-weight: 650; }
.sidebar-link:hover { background: var(--surface-2); color: var(--text-strong); }
.sidebar-link.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: color-mix(in srgb, var(--primary) 18%, transparent);
  font-weight: 700;
}
.sidebar-scrim { display: none; }

.app-content { margin-left: var(--sidebar-w); min-height: 100vh; }
.app-topbar {
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 900;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
}
.mobile-menu-button { display: none; }
.topbar-search {
  flex: 0 1 390px;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--muted);
}
.topbar-search:focus-within { border-color: var(--border-strong); background: var(--surface); }
.topbar-search input {
  border: 0;
  outline: 0;
  background: transparent;
  min-height: 34px;
  padding: 0;
  color: var(--text);
  width: 100%;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.topbar-account-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); }

.app-main {
  width: min(100% - 56px, 1240px);
  margin: 0 auto;
  padding: 34px 0 54px;
}
.app-main.narrow { width: min(100% - 56px, 760px); }
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-title {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  letter-spacing: -.04em;
  line-height: 1.05;
}
.page-subtitle { margin: 8px 0 0; color: var(--muted); max-width: 760px; }
.section-title {
  margin: 28px 0 10px;
  font-size: .94rem;
  color: var(--text-strong);
  letter-spacing: -.01em;
}
.section-kicker { color: var(--muted); font-size: .82rem; font-weight: 650; }

.card, .ui-card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad, .ui-card, .panel { padding: 18px; }
.card-flat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px;
  min-height: 88px;
}
.summary-label { color: var(--muted); font-size: .82rem; font-weight: 650; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.summary-value { margin-top: 8px; font-size: 1.45rem; line-height: 1; letter-spacing: -.035em; color: var(--text-strong); font-weight: 750; }
.summary-foot { margin-top: 5px; color: var(--muted); font-size: .8rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr); gap: 16px; align-items: start; }
.widget-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.widget-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.widget-title { margin: 0; color: var(--text-strong); font-size: 1rem; letter-spacing: -.02em; }
.widget-subtitle { margin: 3px 0 0; color: var(--muted); font-size: .84rem; }

.module-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 94px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.module-card:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
.module-card h2 { margin: 0 0 5px; font-size: .98rem; letter-spacing: -.015em; color: var(--text-strong); }
.module-card p { margin: 0; color: var(--muted); font-size: .86rem; }
.module-card .arrow { color: var(--muted-2); margin-top: 2px; }

button, .btn, input[type="submit"] {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover, .btn:hover, input[type="submit"]:hover { filter: brightness(.98); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger, button.danger { background: var(--danger); color: #fff; }
.btn-warning, button.warn { background: var(--warning); color: #111827; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-full { width: 100%; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: .9rem; font-weight: 650; color: var(--text); margin: 12px 0 5px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .02em; font-weight: 750; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

.badge, .pill, .status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 23px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .78rem;
  font-weight: 750;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}
.badge-danger, .clean-unassigned, .clean-declined { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.badge-warning, .clean-pending { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.badge-success, .clean-confirmed, .status.on { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

.flash, .alert-success { background: var(--success-soft); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 26%, transparent); border-radius: 12px; padding: 10px 12px; margin: 12px 0; }
.error, .alert-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 26%, transparent); border-radius: 12px; padding: 10px 12px; margin: 12px 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

.mini-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.mini-day { min-height: 116px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 9px; overflow: hidden; }
.mini-day.today { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: inset 0 0 0 1px var(--primary-soft); }
.mini-date { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; color: var(--muted); font-size: .78rem; margin-bottom: 7px; }
.mini-date strong { color: var(--text-strong); font-size: 1rem; }
.mini-clean { display: block; border-radius: 7px; padding: 3px 6px; margin: 4px 0; font-size: .74rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent; }
.mini-empty { color: var(--muted-2); font-size: .78rem; margin-top: 8px; }
.status-list { display: grid; gap: 9px; margin-top: 8px; }
.status-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; color: var(--text); }
.status-item:hover { border-color: var(--border-strong); background: var(--surface-3); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--muted-2); flex: none; }
.status-item.urgent .status-dot { background: var(--danger); }
.status-item.warn .status-dot { background: var(--warning); }
.status-item.ok .status-dot { background: var(--success); }
.status-item.info .status-dot { background: var(--info); }
.status-item strong { display: block; font-size: .9rem; color: var(--text-strong); }
.status-item span span { display: block; color: var(--muted); font-size: .82rem; }

.calendar-shell { overflow: hidden; }
.calendar-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.calendar-toolbar form { display: flex; align-items: center; gap: 8px; margin: 0; }
.calendar-legend { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 14px; color: var(--muted); font-size: .84rem; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }
.dot-red { background: #e74c3c; }
.dot-yellow { background: #f1c40f; }
.dot-green { background: #27ae60; }
.dot-gray { background: #95a5a6; }
#calendar { background: var(--surface); color: var(--text); }
.fc { color: var(--text); }
.fc .fc-toolbar-title { color: var(--text-strong); font-size: 1.2rem; letter-spacing: -.02em; }
.fc .fc-button { background: var(--surface-2); border-color: var(--border); color: var(--text); box-shadow: none !important; text-transform: capitalize; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--primary); border-color: var(--primary); color: #fff; }
.fc .fc-daygrid-day, .fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid { border-color: var(--border); }
.fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { color: var(--muted); text-decoration: none; }
.fc .fc-list, .fc .fc-list-table { background: var(--surface); color: var(--text); border-color: var(--border); }
.fc .fc-list-day-cushion { background: var(--surface-2); color: var(--text); }

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 18px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 26px; }
.auth-card h1 { margin: 0 0 8px; font-size: 1.45rem; }

.app-bottom-nav { display: none; }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .widget-row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 286px; }
  .app-sidebar { transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1050; }
  .sidebar-close { display: inline-flex; min-width: 34px; height: 34px; padding: 0; border-radius: 9px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); align-items: center; justify-content: center; }
  .app-content { margin-left: 0; }
  .mobile-menu-button { display: inline-flex; }
  .topbar-search { flex: 1 1 auto; max-width: none; }
  .topbar-account-name { display: none; }
  .app-topbar { padding: 0 14px; }
  .app-main { width: min(100% - 28px, 1240px); padding: 22px 0 86px; }
  .app-main.narrow { width: min(100% - 28px, 760px); }
  .app-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .app-bottom-nav a { flex: 1; min-height: 46px; border-radius: 12px; color: var(--muted); text-decoration: none; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px; font-size: 11px; }
  .app-bottom-nav a.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; }
}

@media (max-width: 680px) {
  .page-header { flex-direction: column; align-items: stretch; margin-bottom: 16px; }
  .summary-grid { grid-template-columns: 1fr; gap: 10px; }
  .summary-card { min-height: auto; }
  .mini-calendar { display: flex; overflow-x: auto; padding-bottom: 2px; scroll-snap-type: x mandatory; }
  .mini-day { min-width: 148px; scroll-snap-align: start; }
  .module-card { min-height: auto; }
  th, td { padding: 9px; }
  .mobile-card-table table, .mobile-card-table thead, .mobile-card-table tbody, .mobile-card-table tr, .mobile-card-table th, .mobile-card-table td { display: block; width: 100%; }
  .mobile-card-table thead { display: none; }
  .mobile-card-table tr { border: 1px solid var(--border); border-radius: 14px; margin: 10px 0; background: var(--surface); padding: 8px; }
  .mobile-card-table td { border: 0; padding: 6px 8px; }
  .mobile-card-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .76rem; font-weight: 750; }
  .calendar-toolbar { align-items: stretch; }
  .calendar-toolbar > *, .calendar-toolbar form { width: 100%; }
  .fc .fc-toolbar.fc-header-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .fc .fc-toolbar-chunk { display: flex; justify-content: center; }
}


/* UI polish patch */
@media (min-width: 901px) {
  .mobile-menu-button { display: inline-flex; }
  body.sidebar-collapsed { --sidebar-w: 70px; }
  body.sidebar-collapsed .sidebar-org-name,
  body.sidebar-collapsed .sidebar-section-toggle span:first-child,
  body.sidebar-collapsed .sidebar-link:not(.active),
  body.sidebar-collapsed .sidebar-section-items { display: none; }
  body.sidebar-collapsed .sidebar-section-toggle { justify-content: center; }
  body.sidebar-collapsed .sidebar-link.active { padding-left: 10px; font-size: 0; }
  body.sidebar-collapsed .sidebar-link.active::before { content: '•'; font-size: 20px; }
}
.topbar-search { position: relative; }
.nav-search-results { display:none; position:absolute; top:calc(100% + 8px); left:0; right:0; background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow); padding:6px; z-index:2000; max-height:360px; overflow:auto; }
.nav-search-results.open { display:block; }
.nav-search-item { display:flex; justify-content:space-between; gap:12px; align-items:center; padding:10px 12px; border-radius:9px; color:var(--text); text-decoration:none; }
.nav-search-item:hover { background:var(--surface-2); }
.nav-search-item span { color:var(--muted); font-size:12px; }
.nav-search-empty { padding:12px; color:var(--muted); }
.action-items .widget-title { margin:0; }
.has-app-shell .legacy-page, .has-app-shell .wrap { max-width:none !important; margin:0 !important; padding:0 !important; width:100%; }
.has-app-shell .legacy-content { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:18px; overflow:auto; }
.has-app-shell .wrap > header, .has-app-shell main > header { display:none !important; }
.has-app-shell table { background:var(--surface); color:var(--text); }
.has-app-shell th, .has-app-shell td { border-color:var(--border) !important; }
.has-app-shell input, .has-app-shell select, .has-app-shell textarea { background:var(--surface); color:var(--text); border:1px solid var(--border-strong); border-radius:10px; padding:8px 10px; }
.has-app-shell button, .has-app-shell .button { border-radius:10px; }
.toast { position:fixed; right:22px; top:76px; z-index:3000; background:var(--surface); border:1px solid var(--border); color:var(--text); padding:12px 14px; border-radius:12px; box-shadow:var(--shadow); max-width:360px; }
.toast.success { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.toast.hide { opacity:0; transform:translateY(-6px); transition:.2s ease; }
@media (max-width: 900px) { .toast { left:14px; right:14px; top:auto; bottom:82px; } }

/* UI stabilization patch */
.dashboard-grid-single { grid-template-columns: 1fr; }
.dashboard-upcoming-card { width: 100%; }
a.mini-clean { color: inherit; text-decoration: none; transition: filter .12s ease, transform .12s ease; }
a.mini-clean:hover { filter: brightness(.96); transform: translateY(-1px); }
.summary-card { transition: border-color .16s ease, background .16s ease, transform .16s ease; }
a.summary-card:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
@media (min-width: 901px) { .dashboard-upcoming-card .mini-day { min-height: 128px; } }


/* Cleanup polish patch: desktop sidebar collapse, dashboard width, search dropdown, guest composer visibility */
@media (min-width: 901px) {
  body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .app-content { margin-left: 0; }
  body.sidebar-collapsed { --sidebar-w: 224px; }
}
.topbar-search { position: relative; max-width: 430px; }
.nav-search-results {
  min-width: 420px;
  right: auto;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  box-shadow: 0 18px 50px rgba(15,23,42,.16) !important;
  padding: 7px !important;
  overflow: auto;
}
.nav-search-results.open { display: block !important; }
.nav-search-item {
  display: grid !important;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px !important;
  border-radius: 10px !important;
  color: var(--text) !important;
  text-decoration: none !important;
  line-height: 1.25;
}
.nav-search-item strong { color: var(--text-strong); font-size: 13px; }
.nav-search-item span { color: var(--muted); font-size: 12px; }
.nav-search-item:hover, .nav-search-item.is-active { background: var(--surface-2) !important; }
.nav-search-empty { padding: 12px; color: var(--muted); }
.dashboard-wide .app-main { width: min(100% - 56px, 1360px); }
.dashboard-full-card { width: 100%; }
.dashboard-full-card .mini-calendar { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.mini-day.open-calendar-tile { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; color: var(--text-strong); font-weight: 800; background: var(--surface); }
.mini-day.open-calendar-tile:hover { background: var(--surface-2); border-color: var(--border-strong); }
.quick-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 16px; }
.quick-action-card { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.quick-action-card:hover { background: var(--surface-2); border-color: var(--border-strong); }
.quick-action-card strong { display: block; color: var(--text-strong); margin-bottom: 4px; }
.quick-action-card span { color: var(--muted); font-size: .84rem; }
@media (max-width: 900px) {
  .nav-search-results { min-width: 0; width: min(420px, calc(100vw - 28px)); }
}
@media (max-width: 680px) {
  .dashboard-full-card .mini-calendar { display: flex; overflow-x: auto; }
  .mini-day.open-calendar-tile { min-width: 148px; }
}


/* Final polish patch */
@media (min-width: 901px) {
  .mobile-menu-button { display: none !important; }
  .sidebar-collapse-tab {
    display: inline-flex;
    position: fixed;
    left: calc(var(--sidebar-w) - 1px);
    top: 84px;
    z-index: 1201;
    width: 26px;
    height: 54px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 12px 12px 0;
    background: var(--sidebar-bg, var(--surface));
    color: var(--muted);
    box-shadow: var(--shadow);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
  }
  .sidebar-collapse-tab:hover { color: var(--text-strong); background: var(--surface-2); }
  body.sidebar-collapsed .sidebar-collapse-tab { left: 0; border-left: 1px solid var(--border); border-radius: 0 12px 12px 0; }
  body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .app-content { margin-left: 0 !important; }
}
@media (max-width: 900px) { .sidebar-collapse-tab { display: none !important; } }

/* Keep supervisor assignment rows neutral; status lives in the pill only. */
.clean-supervisor-page .grid.row.status-unassigned,
.clean-supervisor-page .grid.row.status-pending,
.clean-supervisor-page .grid.row.status-confirmed {
  background: var(--surface) !important;
  border-left-width: 0 !important;
}
.clean-supervisor-page .grid.row.status-unassigned:hover,
.clean-supervisor-page .grid.row.status-pending:hover,
.clean-supervisor-page .grid.row.status-confirmed:hover { background: var(--surface-2) !important; }
.clean-supervisor-page .status-badge.status-unassigned { color: var(--danger) !important; background: var(--danger-soft) !important; border-color: color-mix(in srgb,var(--danger) 35%,var(--border)) !important; }
.clean-supervisor-page .status-badge.status-pending { color: var(--warning) !important; background: var(--warning-soft) !important; border-color: color-mix(in srgb,var(--warning) 38%,var(--border)) !important; }
.clean-supervisor-page .status-badge.status-confirmed { color: var(--success) !important; background: var(--success-soft) !important; border-color: color-mix(in srgb,var(--success) 35%,var(--border)) !important; }

/* Clean detail page final polish */
.clean-page .btn, .clean-page .file-btn, .clean-page .btnlink { background: var(--accent); color: #fff; border-color: color-mix(in srgb, var(--accent) 70%, transparent); }
.clean-page .btn.danger { background: var(--danger); border-color: color-mix(in srgb,var(--danger) 70%, transparent); }
.clean-page .card { border-color: var(--border); background: var(--surface); box-shadow: var(--shadow); }
.clean-page .badge.ok, .clean-page .badge.success { background: var(--success-soft); color: var(--success); }
.clean-page .badge.warn { background: var(--warning-soft); color: var(--warning); }
.clean-page .badge.bad, .clean-page .badge.problem { background: var(--danger-soft); color: var(--danger); }
.clean-page .completion-warning { margin: 10px 0; padding: 10px 12px; border-radius: 12px; border: 1px solid color-mix(in srgb,var(--warning) 35%,var(--border)); background: var(--warning-soft); color: var(--text); }


/* Cleanup polish 2: search focus, sidebar collapse control, follow-up inbox cleanup */
:root { --accent: var(--primary); }

/* Search should be one clean input. The wrapper should not draw its own focused box. */
.topbar-search {
  position: relative;
  flex: 0 1 430px;
  max-width: 430px;
  min-height: 42px;
  padding: 0 !important;
  gap: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--muted);
}
.topbar-search:focus-within {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.topbar-search > span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  pointer-events: none;
  color: var(--muted);
}
.topbar-search input {
  width: 100% !important;
  min-height: 42px !important;
  padding: 0 12px 0 40px !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 12px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  outline: 0 !important;
}
.topbar-search input:focus {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border-strong)) !important;
  box-shadow: 0 0 0 3px var(--primary-soft) !important;
}
.topbar-search .nav-search-results {
  left: 0;
  top: calc(100% + 8px);
}

/* Desktop: collapse control lives in the sidebar header. The external tab only appears after collapse as a small reopen handle. */
.sidebar-collapse-inline {
  display: none;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  box-shadow: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.sidebar-collapse-inline:hover { background: var(--surface-2); color: var(--text-strong); }
@media (min-width: 901px) {
  .sidebar-collapse-inline { display: inline-flex; }
  .sidebar-close { display: none !important; }
  .sidebar-collapse-tab { display: none !important; }
  body.sidebar-collapsed .sidebar-collapse-tab {
    display: inline-flex !important;
    position: fixed;
    left: 0;
    top: 76px;
    z-index: 1201;
    width: 24px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 10px 10px 0;
    background: var(--surface);
    color: var(--muted);
    box-shadow: 0 1px 4px rgba(15,23,42,.08);
    cursor: pointer;
    font-size: 18px;
  }
  body.sidebar-collapsed .sidebar-collapse-tab:hover { background: var(--surface-2); color: var(--text-strong); }
}
@media (max-width: 900px) {
  .sidebar-collapse-inline, .sidebar-collapse-tab { display: none !important; }
  .topbar-search { flex: 1 1 auto; max-width: none; }
}

/* Follow-up Inbox small cleanup */
.followup-page .toolbar .old-dashboard-link,
.followup-page .toolbar .old-logout-link,
.followup-page #flash:empty { display: none !important; }
.followup-page #flash:not(:empty) { display: inline-flex; }
.followup-page .toolbar h1 { margin-top: 0; }

/* Show-all group label on supervisor rows */
.clean-supervisor-page .group-mini-label {
  display: inline-flex;
  align-items: center;
  margin-top: 3px;
  font-size: .74rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}
.view-as-form{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--border);background:var(--surface);border-radius:10px;padding:0 8px;height:34px;color:var(--text)}
.view-as-form select{border:0;background:transparent;color:var(--text);font-weight:700;max-width:170px;outline:0}
.view-as-banner{position:sticky;top:var(--topbar-h);z-index:899;background:var(--warning-soft);color:var(--warning);border-bottom:1px solid color-mix(in srgb,var(--warning) 35%,var(--border));padding:8px 28px;font-weight:800;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.view-as-banner form{display:inline}.view-as-banner button{border:1px solid currentColor;background:transparent;color:inherit;border-radius:999px;padding:4px 10px;font-weight:800;cursor:pointer}
@media(max-width:700px){.view-as-form select{max-width:120px}.view-as-banner{padding:8px 14px}}
