:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f8f9fc;
  --border: #e3e7ef;
  --border-strong: #d3d9e4;
  --text: #1a2233;
  --text-muted: #667085;
  --text-faint: #98a2b3;
  --primary: #2f5dd4;
  --primary-dark: #234ab0;
  --primary-light: #e8eefc;
  --success: #12875a;
  --success-light: #e3f6ec;
  --warning: #b7791f;
  --warning-light: #fdf3d9;
  --danger: #d43f3f;
  --danger-light: #fbe6e6;
  --purple: #7c4fd6;
  --purple-light: #efe6fc;
  --gray-light: #eef0f4;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, 0.06);
  --shadow: 0 4px 16px rgba(20, 30, 60, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 30, 60, 0.16);
  --sidebar-w: 236px;
  --topbar-h: 60px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Inter, -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
::selection { background: var(--primary-light); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #3a67dd, #1c2f66 65%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 36px 34px 30px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .logo-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #6f8ff0); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.login-brand h1 { font-size: 17px; }
.login-brand span { display: block; font-size: 12px; color: var(--text-muted); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.field textarea { resize: vertical; min-height: 70px; font-family: inherit; }
.btn-primary {
  width: 100%; padding: 11px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--primary-dark); }
.login-error { background: var(--danger-light); color: var(--danger); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--text-faint); line-height: 1.6; background: var(--surface-alt); padding: 10px 12px; border-radius: var(--radius-sm); }
.login-hint b { color: var(--text-muted); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #161d34; color: #cfd6ec;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.sidebar-brand .logo-mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), #6f8ff0); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.sidebar-brand div { font-size: 13.5px; font-weight: 700; color: #fff; line-height: 1.25; }
.sidebar-brand small { display: block; font-weight: 400; color: #8891ae; font-size: 10.5px; }
.sidebar nav { flex: 1; padding: 8px 10px 20px; }
.nav-group { margin-top: 14px; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: #6d7699; padding: 0 10px; margin-bottom: 4px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 13.5px;
  color: #c3cae4; cursor: pointer; margin-bottom: 1px; transition: background .12s, color .12s;
}
.nav-item:hover { background: #232c4d; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ic { width: 17px; text-align: center; font-size: 14px; }
.nav-item .count { margin-left: auto; background: rgba(255,255,255,.14); font-size: 11px; padding: 1px 6px; border-radius: 20px; }
.nav-item.active .count { background: rgba(255,255,255,.25); }

.main-area { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.global-search { position: relative; flex: 1; max-width: 420px; }
.global-search input {
  width: 100%; padding: 8px 12px 8px 34px; border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface-alt);
  font-size: 13.5px;
}
.global-search input:focus { outline: none; border-color: var(--primary); background: #fff; }
.global-search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 13px; }
.search-results {
  position: absolute; top: 40px; left: 0; width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; padding: 6px; z-index: 60;
}
.search-results .sr-group { font-size: 10.5px; text-transform: uppercase; color: var(--text-faint); font-weight: 700; padding: 8px 10px 3px; }
.search-results .sr-item { padding: 7px 10px; border-radius: 7px; font-size: 13.5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.search-results .sr-item:hover { background: var(--surface-alt); }
.search-results .sr-empty { padding: 16px; text-align: center; color: var(--text-faint); font-size: 13px; }

.topbar-spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid transparent; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--text-muted); position: relative; transition: background .12s;
}
.icon-btn:hover { background: var(--surface-alt); }
.badge-dot { position: absolute; top: 5px; right: 6px; background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 700; min-width: 15px; height: 15px; border-radius: 20px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 6px; border-radius: 22px; cursor: pointer; transition: background .12s; }
.user-chip:hover { background: var(--surface-alt); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-size: 13px; }
.user-chip .who span { font-size: 11px; color: var(--text-muted); }

.dropdown-panel { position: absolute; top: 52px; right: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 340px; max-height: 480px; overflow-y: auto; z-index: 60; }
.dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; font-weight: 700; }
.dropdown-header a { font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer; }
.notif-item { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 10px; }
.notif-item:hover { background: var(--surface-alt); }
.notif-item.unread { background: #f5f8ff; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink: 0; }
.notif-dot.read { background: transparent; }
.notif-item .ntitle { font-size: 13px; font-weight: 600; }
.notif-item .nbody { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.notif-item .ntime { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; }
.dropdown-empty { padding: 30px 14px; text-align: center; color: var(--text-faint); font-size: 13px; }
.user-menu-item { padding: 10px 14px; font-size: 13.5px; cursor: pointer; display: flex; align-items: center; gap: 9px; }
.user-menu-item:hover { background: var(--surface-alt); }

.content { flex: 1; padding: 22px 26px 60px; max-width: 1400px; width: 100%; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 21px; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn { padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); transition: all .12s; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.btn:hover { background: var(--surface-alt); border-color: var(--text-faint); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--danger-light); border-color: var(--danger-light); color: var(--danger); }
.btn.danger:hover { background: #f6cccc; }
.btn.success { background: var(--success-light); border-color: var(--success-light); color: var(--success); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-alt); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }
.icon-only { padding: 7px 9px; }

/* ---------- Cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; cursor: pointer; transition: box-shadow .15s, transform .1s; }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card .stat-num { font-size: 25px; font-weight: 750; line-height: 1.15; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }
.stat-card.accent-danger .stat-num { color: var(--danger); }
.stat-card.accent-warning .stat-num { color: var(--warning); }
.stat-card.accent-success .stat-num { color: var(--success); }
.stat-card.accent-primary .stat-num { color: var(--primary); }

.section-title { font-size: 14.5px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; justify-content: space-between; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill.gray { background: var(--gray-light); color: var(--text-muted); }
.pill.blue { background: var(--primary-light); color: var(--primary-dark); }
.pill.green { background: var(--success-light); color: var(--success); }
.pill.amber { background: var(--warning-light); color: var(--warning); }
.pill.red { background: var(--danger-light); color: var(--danger); }
.pill.purple { background: var(--purple-light); color: var(--purple); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.data-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-alt); white-space: nowrap; }
table.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { cursor: pointer; transition: background .1s; }
table.data-table tbody tr:hover { background: var(--surface-alt); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-faint); }
.empty-state .ic { font-size: 30px; margin-bottom: 10px; }
.empty-state b { display: block; color: var(--text-muted); font-size: 14px; margin-bottom: 4px; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.filter-bar select, .filter-bar input[type=text], .filter-bar input[type=date] { padding: 6px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); font-size: 12.5px; background: var(--surface-alt); }
.filter-bar .fb-search { flex: 1; min-width: 160px; }
.view-toggle { display: flex; background: var(--surface-alt); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.view-toggle button { border: none; background: transparent; padding: 6px 11px; font-size: 12.5px; font-weight: 600; border-radius: 6px; cursor: pointer; color: var(--text-muted); }
.view-toggle button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------- Kanban ---------- */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-col { background: var(--surface-alt); border-radius: var(--radius); min-width: 270px; max-width: 270px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.kanban-col-head { padding: 12px 14px 8px; font-size: 12.5px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); }
.kanban-col-body { padding: 0 10px 10px; overflow-y: auto; flex: 1; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow-sm); }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: .4; }
.kanban-card .kc-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; line-height: 1.35; }
.kanban-card .kc-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-faint); margin-top: 7px; }
.kanban-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; }

/* ---------- Calendar ---------- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.calendar-dow { background: var(--surface-alt); padding: 8px; text-align: center; font-size: 11px; font-weight: 700; color: var(--text-faint); }
.calendar-cell { background: var(--surface); min-height: 100px; padding: 6px; font-size: 11.5px; }
.calendar-cell .cc-num { font-size: 11.5px; color: var(--text-faint); font-weight: 700; margin-bottom: 4px; }
.calendar-cell.today .cc-num { color: #fff; background: var(--primary); width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.calendar-cell.out { background: var(--surface-alt); opacity: .5; }
.cal-item { background: var(--primary-light); color: var(--primary-dark); border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; font-size: 10.5px; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.late { background: var(--danger-light); color: var(--danger); }
.cal-item.done { background: var(--success-light); color: var(--success); text-decoration: line-through; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 20, 35, .5); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; }
.modal.wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-faint); width: 30px; height: 30px; border-radius: 50%; }
.modal-close:hover { background: var(--surface-alt); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Toasts ---------- */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1a2233; color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-lg); min-width: 220px; animation: toast-in .18s ease-out; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Flow detail / timeline ---------- */
.flow-progress-bar { height: 8px; border-radius: 20px; background: var(--gray-light); overflow: hidden; }
.flow-progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), #6f8ff0); border-radius: 20px; transition: width .3s; }
.step-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.step-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.step-row.done { background: var(--success-light); border-color: #cdeedd; }
.step-row.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.step-row.locked { opacity: .55; }
.step-row.late { border-color: #f3c5c5; background: var(--danger-light); }
.step-icon { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; background: var(--gray-light); color: var(--text-faint); }
.step-row.done .step-icon { background: var(--success); color: #fff; }
.step-row.active .step-icon { background: var(--primary); color: #fff; }
.step-main { flex: 1; min-width: 0; }
.step-main .sm-title { font-size: 13.5px; font-weight: 650; }
.step-main .sm-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.step-actions { display: flex; gap: 6px; flex-shrink: 0; }

.comment-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.comment-item { display: flex; gap: 10px; }
.comment-bubble { background: var(--surface-alt); border-radius: var(--radius-sm); padding: 9px 12px; flex: 1; }
.comment-bubble .cb-head { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 3px; }
.comment-bubble .cb-head b { font-size: 12.5px; }
.comment-bubble .cb-head span { color: var(--text-faint); }
.comment-bubble .cb-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form textarea { flex: 1; min-height: 42px; }

.history-list { display: flex; flex-direction: column; gap: 0; margin-top: 6px; }
.history-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.history-row:last-child { border-bottom: none; }
.history-row .h-time { color: var(--text-faint); white-space: nowrap; font-size: 11px; min-width: 118px; }
.history-row b { font-weight: 650; }

.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-bar button { background: none; border: none; padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-bar button.active { color: var(--primary); border-bottom-color: var(--primary); }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--text-muted); }
.info-row span:last-child { font-weight: 600; text-align: right; }

.builder-step { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; background: var(--surface-alt); }
.builder-step-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.builder-step-head .bs-num { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.dep-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-light); color: var(--primary-dark); border-radius: 20px; padding: 3px 9px; font-size: 11.5px; margin: 2px 3px 2px 0; }
.dep-chip button { background: none; border: none; cursor: pointer; color: inherit; font-size: 12px; padding: 0; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.important-note { background: var(--warning-light); border: 1px solid #f2dfa8; color: #7a5915; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start; }

.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; background: var(--surface-alt); border-radius: var(--radius-sm); font-size: 12.5px; cursor: pointer; }
.mini-row:hover { background: var(--gray-light); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.saved-chip { padding: 5px 11px; border-radius: 20px; background: var(--surface-alt); border: 1px solid var(--border); font-size: 12px; cursor: pointer; }
.saved-chip:hover { border-color: var(--primary); color: var(--primary); }

.loader { display: flex; align-items: center; justify-content: center; padding: 60px 0; color: var(--text-faint); font-size: 13px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .7s linear infinite; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }

.link-btn { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.flex { display: flex; } .flex-gap { display: flex; gap: 8px; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.text-right { text-align: right; }
.small { font-size: 12px; }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .content { padding: 16px; }
}

/* ---------- Agenda ---------- */
.color-gray { --c-bg: var(--gray-light); --c-border: var(--text-muted); --c-text: var(--text); --c-solid: var(--text-muted); }
.color-blue { --c-bg: var(--primary-light); --c-border: var(--primary); --c-text: var(--primary-dark); --c-solid: var(--primary); }
.color-green { --c-bg: var(--success-light); --c-border: var(--success); --c-text: var(--success); --c-solid: var(--success); }
.color-amber { --c-bg: var(--warning-light); --c-border: var(--warning); --c-text: var(--warning); --c-solid: var(--warning); }
.color-red { --c-bg: var(--danger-light); --c-border: var(--danger); --c-text: var(--danger); --c-solid: var(--danger); }
.color-purple { --c-bg: var(--purple-light); --c-border: var(--purple); --c-text: var(--purple); --c-solid: var(--purple); }

.calendar-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c-solid, var(--text-faint)); flex-shrink: 0; }

.agenda-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.agenda-nav { display: flex; align-items: center; gap: 8px; }
.agenda-nav h3 { font-size: 14.5px; min-width: 170px; text-align: center; text-transform: capitalize; }

.calendar-picker { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-width: 190px; max-height: 260px; overflow-y: auto; }
.calendar-picker-item { display: flex; align-items: center; gap: 8px; padding: 6px 7px; border-radius: 6px; font-size: 12.5px; cursor: pointer; }
.calendar-picker-item:hover { background: var(--surface-alt); }
.calendar-picker-item input { flex-shrink: 0; }
.calendar-picker-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.time-grid-wrap { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.time-grid-head { display: flex; border-bottom: 1px solid var(--border); }
.time-grid-head-spacer { width: 54px; flex-shrink: 0; }
.time-grid-head-day { flex: 1; min-width: 92px; text-align: center; padding: 9px 4px; font-size: 12px; font-weight: 700; border-left: 1px solid var(--border); }
.time-grid-head-day:first-child { border-left: none; }
.time-grid-head-day.today { color: var(--primary); }
.time-grid-head-day .thd-num { display: block; font-size: 15px; margin-top: 2px; }

.all-day-row { display: flex; border-bottom: 1px solid var(--border); background: var(--surface-alt); min-height: 28px; }
.all-day-label { width: 54px; flex-shrink: 0; font-size: 9.5px; color: var(--text-faint); padding: 6px; }
.all-day-events { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 6px; }

.time-grid-scroll { display: flex; max-height: 620px; overflow: auto; }
.time-grid-hours { width: 54px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--surface-alt); position: sticky; left: 0; z-index: 3; }
.time-grid-hour { height: 48px; font-size: 10.5px; color: var(--text-faint); text-align: right; padding: 0 6px; box-sizing: border-box; position: relative; }
.time-grid-hour span { position: absolute; right: 6px; top: -6px; background: var(--surface-alt); }
.time-grid-days { flex: 1; display: flex; position: relative; min-width: 0; }
.time-grid-day-col { flex: 1; min-width: 92px; position: relative; border-left: 1px solid var(--border); }
.time-grid-day-col:first-child { border-left: none; }
.time-grid-hour-line { height: 48px; border-bottom: 1px dashed var(--border); box-sizing: border-box; }
.time-grid-hour-line.unavailable { background: repeating-linear-gradient(135deg, var(--surface-alt) 0 8px, var(--bg) 8px 16px); }
.time-grid-now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.time-grid-now-line::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

.event-block { position: absolute; left: 2px; right: 2px; border-radius: 5px; padding: 3px 6px; font-size: 11px; line-height: 1.3; overflow: hidden; cursor: pointer; border-left: 3px solid var(--c-border, var(--primary)); background: var(--c-bg, var(--primary-light)); color: var(--c-text, var(--primary-dark)); box-shadow: var(--shadow-sm); z-index: 2; }
.event-block:hover { box-shadow: var(--shadow); z-index: 3; }
.event-block .eb-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-block .eb-time { opacity: .8; font-size: 9.5px; }
.event-block.is-block { opacity: .8; }

.agenda-month-item { display: block; border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; font-size: 10.5px; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid var(--c-border, var(--primary)); background: var(--c-bg, var(--primary-light)); color: var(--c-text, var(--primary-dark)); }

.access-level-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.access-level-row:last-child { border-bottom: none; }

/* ---------- Popover + search-select dropdown (App.ui.openPopover / searchSelect) ---------- */
.popover { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 150; padding: 10px; max-height: 380px; overflow-y: auto; }
.search-select-dropdown { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 150; max-height: 280px; overflow-y: auto; padding: 4px; }
.ssd-item { padding: 7px 10px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.ssd-item:hover, .ssd-item.active { background: var(--surface-alt); }
.ssd-empty { padding: 14px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* ---------- Emoji picker (App.ui.openEmojiPicker) ---------- */
.emoji-picker-search { width: 100%; box-sizing: border-box; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 8px; }
.emoji-picker-grid { max-height: 280px; overflow-y: auto; }
.emoji-picker-section-label { font-size: 10.5px; text-transform: uppercase; color: var(--text-faint); font-weight: 700; padding: 6px 2px 3px; }
.emoji-picker-row { display: flex; flex-wrap: wrap; gap: 2px; }
.emoji-picker-btn { border: none; background: transparent; font-size: 19px; line-height: 1; padding: 5px; border-radius: 7px; cursor: pointer; }
.emoji-picker-btn:hover { background: var(--surface-alt); }
.icon-pick-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; font-size: 19px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.icon-pick-btn:hover { background: var(--surface-alt); }

/* ---------- Horizontal calendar picker (replaces the old vertical checkbox list) ---------- */
.calendar-picker-row { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow: hidden; }
.calendar-pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.calendar-pill.selected { border-color: var(--c-solid, var(--primary)); background: var(--c-bg, var(--primary-light)); color: var(--c-text, var(--primary-dark)); }
.calendar-pill .cp-icon { font-size: 13px; }
.calendar-picker-more { flex-shrink: 0; }
.calendar-popover-item { display: flex; align-items: center; gap: 8px; padding: 7px; border-radius: 7px; font-size: 12.5px; cursor: pointer; }
.calendar-popover-item:hover { background: var(--surface-alt); }
.calendar-popover-search { width: 100%; box-sizing: border-box; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 8px; }

/* ---------- Availability layer (precise, minute-based, behind events) ---------- */
.availability-block { position: absolute; left: 0; right: 0; background: var(--primary-light); opacity: .35; pointer-events: none; z-index: 1; }

/* ---------- Flow matrix report (sticky first column + horizontal scroll) ---------- */
.matrix-scroll { overflow-x: auto; }
.matrix-table { border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.matrix-table th, .matrix-table td { border: 1px solid var(--border); padding: 7px 10px; }
.matrix-table thead th { background: var(--surface-alt); position: sticky; top: 0; z-index: 2; }
.matrix-table td:first-child, .matrix-table th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; font-weight: 600; }
.matrix-table thead th:first-child { z-index: 3; }
.matrix-table .agg-tile { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
