:root {
  --brand: #0B5EA8; --brand-mid: #1A7EC4; --brand-light: #7DD4F8; --brand-pale: #E3F4FD;
  --dark: #0A1F3A; --cream: #F2F8FC; --gray: #5F5E5A;
  --red: #C0392B; --amber: #D4800A; --blue: #1A5F8E; --purple:#9B59B6;
  --white: #FFFFFF; --border: rgba(0,0,0,0.08);
}
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: Arial, sans-serif; background: #F2F4F0; color: var(--dark); font-size: 14px; }
code { background:#EEE; padding:2px 5px; border-radius:4px; font-size:12px; }

/* ===================== LOGIN ===================== */
.login-screen { min-height:100vh; display:flex; align-items:center; justify-content:center; background: linear-gradient(135deg, var(--dark), #123); }
.login-card { background:white; border-radius:16px; padding:40px; width:380px; box-shadow:0 20px 60px rgba(0,0,0,0.3); }
.login-logo { display:flex; align-items:center; gap:10px; justify-content:center; margin-bottom:8px; }
.login-logo-text { font-size:20px; font-weight:700; color: var(--dark); }
.login-sub { text-align:center; font-size:13px; color:var(--gray); margin-bottom:28px; }
.login-error { color: var(--red); font-size:13px; margin-bottom:12px; min-height:18px; }
.login-hint { font-size:11px; color:var(--gray); margin-top:20px; text-align:center; line-height:1.5; }

/* ===================== LAYOUT ===================== */
.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; background: var(--dark); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.sidebar { background: var(--dark); padding: 0; border-right: 1px solid rgba(255,255,255,0.06); overflow-y: auto; display:flex; flex-direction:column; }
.main { overflow-y: auto; }

/* BUSINESS SWITCHER */
.biz-switcher { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.biz-option { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 6px; border: 1.5px solid transparent; transition: all 0.15s; }
.biz-option:hover { background: rgba(255,255,255,0.05); }
.biz-option.active { background: rgba(255,255,255,0.08); border-color: var(--biz-color, var(--brand)); }
.biz-dot { width: 28px; height: 28px; border-radius: 7px; display:flex; align-items:center; justify-content:center; font-size:14px; flex-shrink:0; }
.biz-name { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.9); }
.biz-sub { font-size: 10px; color: rgba(255,255,255,0.4); }

/* TOP BAR */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { color: var(--brand-light); font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.tb-btn { background: var(--brand); color: white; border: none; padding: 8px 18px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600; }
.tb-date { color: rgba(255,255,255,0.45); font-size: 12px; }

.user-menu { position:relative; }
.user-avatar { width:32px; height:32px; border-radius:50%; background:var(--brand); color:white; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; cursor:pointer; }
.user-dropdown { display:none; position:absolute; right:0; top:42px; background:white; border-radius:10px; box-shadow:0 8px 30px rgba(0,0,0,0.18); width:220px; padding:14px; z-index:500; }
.user-dropdown.open { display:block; }
.ud-name { font-weight:700; font-size:13px; }
.ud-email { font-size:12px; color:var(--gray); }
.ud-role { font-size:11px; color:var(--brand); text-transform:uppercase; font-weight:700; margin-top:4px; }
.user-dropdown hr { border:none; border-top:1px solid var(--border); margin:10px 0; }
.ud-item { padding:8px 4px; font-size:13px; cursor:pointer; border-radius:6px; color:var(--dark); }
.ud-item:hover { background:#F5F5F3; }

/* SIDEBAR NAV */
.nav-wrap { flex:1; padding: 12px 0; overflow-y:auto; }
.nav-section { padding: 6px 16px; font-size: 10px; letter-spacing: 2px; color: rgba(255,255,255,0.3); text-transform: uppercase; margin: 12px 0 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; cursor: pointer; color: rgba(255,255,255,0.55); font-size: 13px; border-left: 3px solid transparent; transition: all 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-item.active { background: rgba(255,255,255,0.08); color: var(--brand-light); border-left-color: var(--brand-light); }
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; }
.nav-badge { margin-left: auto; background: var(--brand); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.admin-only { display:none; }
body.is-admin .admin-only { display: flex; }
body.is-admin .nav-section.admin-only { display: block; }

/* PAGES */
.page { padding: 24px; display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 24px; display:flex; align-items:center; justify-content:space-between; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--dark); }
.page-header p { font-size: 13px; color: var(--gray); margin-top: 4px; }
.biz-pill { display:inline-flex; align-items:center; gap:6px; padding:5px 12px; border-radius:16px; font-size:12px; font-weight:700; background: var(--brand-pale); color: var(--brand); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric { background: white; border-radius: 12px; padding: 20px; border: 1px solid var(--border); }
.metric-label { font-size: 11px; color: var(--gray); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.metric-value { font-size: 28px; font-weight: 700; color: var(--dark); }
.metric-sub { font-size: 12px; color: var(--brand); margin-top: 4px; }
.metric.highlight { background: var(--brand); }
.metric.highlight .metric-label { color: rgba(255,255,255,0.6); }
.metric.highlight .metric-value { color: white; }
.metric.highlight .metric-sub { color: var(--brand-light); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card { background: white; border-radius: 12px; padding: 20px; border: 1px solid var(--border); }
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--dark); }
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.act-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.act-text { font-size: 13px; color: var(--dark); }
.act-time { font-size: 11px; color: var(--gray); margin-top: 2px; }

.combined-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap:16px; margin-bottom:24px; }
.combined-card { border-radius:12px; padding:22px; color:white; cursor:pointer; transition: transform 0.15s; }
.combined-card:hover { transform: translateY(-2px); }
.combined-card .cc-label { font-size:11px; letter-spacing:1px; text-transform:uppercase; opacity:0.7; margin-bottom:10px; }
.combined-card .cc-value { font-size:30px; font-weight:700; margin-bottom:4px; }
.combined-card .cc-meta { font-size:12px; opacity:0.85; }

/* PIPELINE */
.pipeline { overflow-x: auto; }
.pipeline-board { display: flex; gap: 16px; min-width: 900px; padding-bottom: 12px; }
.stage-col { flex: 1; min-width: 200px; }
.stage-header { padding: 10px 14px; border-radius: 8px 8px 0 0; font-size: 12px; font-weight: 700; letter-spacing: 0.5px; display: flex; align-items: center; justify-content: space-between; }
.stage-count { background: rgba(255,255,255,0.3); border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.stage-cards { min-height: 300px; padding: 8px; background: rgba(0,0,0,0.03); border-radius: 0 0 8px 8px; border: 1px solid var(--border); border-top: none; }
.deal-card { background: white; border-radius: 8px; padding: 14px; margin-bottom: 8px; border: 1px solid var(--border); cursor: pointer; transition: box-shadow 0.15s; }
.deal-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.deal-name { font-weight: 700; font-size: 13px; color: var(--dark); margin-bottom: 4px; }
.deal-meta { font-size: 12px; color: var(--gray); }
.deal-value { font-size: 14px; font-weight: 700; color: var(--brand); margin-top: 8px; }
.deal-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-top: 6px; }
.tag-res { background: var(--brand-pale); color: var(--brand); }
.tag-com { background: #E3EFF7; color: #1A5F8E; }
.deal-days { font-size: 11px; color: var(--gray); margin-top: 6px; }

/* TOOLBAR / TABLE */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search-box { flex: 1; max-width: 280px; padding: 9px 14px; border: 1px solid #DDD; border-radius: 8px; font-size: 13px; outline: none; }
.search-box:focus { border-color: var(--brand); }
.filter-btn { padding: 8px 14px; border: 1px solid #DDD; border-radius: 8px; background: white; cursor: pointer; font-size: 13px; color: var(--gray); }
.filter-btn.active { border-color: var(--brand); color: var(--brand); background: var(--brand-pale); }
.add-btn { padding: 9px 18px; background: var(--brand); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; margin-left: auto; }
table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
th { background: #F8F8F6; text-align: left; padding: 12px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--gray); font-weight: 700; border-bottom: 1px solid var(--border); }
td { padding: 13px 16px; border-bottom: 1px solid #F5F5F3; font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAF8; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.s-new { background:var(--brand-pale); color:var(--brand); }
.s-contacted { background:#EDF4FB; color:#1A5F8E; }
.s-quoted { background:#FEF3E2; color:#D4800A; }
.s-won { background:var(--brand-pale); color:var(--brand); }
.s-lost { background:#FDEEEE; color:#C0392B; }
.action-btns { display:flex; gap:6px; }
.action-btn { padding:7px 12px; border:1px solid #DDD; border-radius:6px; background:white; cursor:pointer; font-size:12px; color:var(--gray); }
.action-btn:hover { border-color:var(--brand); color:var(--brand); }
.action-btn.primary { background:var(--brand); color:white; border-color:var(--brand); }

/* MODAL */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.45); z-index:1000; display:none; align-items:center; justify-content:center; }
.modal-overlay.open { display:flex; }
.modal { background:white; border-radius:16px; padding:32px; width:560px; max-width:95vw; max-height:90vh; overflow-y:auto; }
.modal h2 { font-size:18px; font-weight:700; margin-bottom:20px; color:var(--dark); }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:14px; }
.form-group { margin-bottom:14px; }
.form-group label { display:block; font-size:12px; font-weight:700; color:var(--gray); margin-bottom:5px; text-transform:uppercase; letter-spacing:0.5px; }
.form-group input, .form-group select, .form-group textarea { width:100%; padding:10px 12px; border:1px solid #DDD; border-radius:8px; font-size:13px; outline:none; font-family:Arial,sans-serif; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color:var(--brand); }
.form-group input:disabled { background:#F5F5F3; color:var(--gray); }
.form-group textarea { height:80px; resize:vertical; }
.modal-actions { display:flex; gap:10px; justify-content:flex-end; margin-top:20px; }
.btn-cancel { padding:10px 20px; border:1px solid #DDD; border-radius:8px; background:white; cursor:pointer; font-size:13px; }
.btn-save { padding:10px 24px; background:var(--brand); color:white; border:none; border-radius:8px; cursor:pointer; font-size:13px; font-weight:700; }
.checkbox-list { display:flex; flex-direction:column; gap:8px; padding:10px; border:1px solid #DDD; border-radius:8px; }
.checkbox-list label { display:flex; align-items:center; gap:8px; font-size:13px; font-weight:400; text-transform:none; }
.send-status { font-size:13px; padding:10px 12px; border-radius:8px; margin-bottom:6px; display:none; }
.send-status.ok { display:block; background:#E3F4FD; color:#0B5EA8; }
.send-status.err { display:block; background:#FDEEEE; color:#C0392B; }
.send-status.info { display:block; background:#FEF3E2; color:#D4800A; }

/* LEAD DETAIL */
.detail-modal { width:680px; }
.detail-header { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:24px; }
.detail-name { font-size:22px; font-weight:700; color:var(--dark); }
.detail-sub { font-size:13px; color:var(--gray); margin-top:4px; }
.close-btn { width:32px; height:32px; background:#F5F5F3; border:none; border-radius:50%; cursor:pointer; font-size:18px; color:var(--gray); display:flex; align-items:center; justify-content:center; }
.detail-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:20px; }
.detail-field label { font-size:11px; font-weight:700; color:var(--gray); text-transform:uppercase; letter-spacing:0.5px; margin-bottom:3px; display:block; }
.detail-field p { font-size:14px; color:var(--dark); }
.notes-area { background:#F8F8F6; border-radius:8px; padding:14px; font-size:13px; color:var(--dark); line-height:1.6; margin-bottom:16px; border:1px solid var(--border); }
.stage-progress { display:flex; gap:0; margin-bottom:20px; overflow:hidden; border-radius:8px; }
.stage-pill { flex:1; padding:8px 4px; text-align:center; font-size:11px; font-weight:700; background:#F0F0EC; color:var(--gray); border-right:1px solid white; cursor:pointer; transition:all 0.15s; }
.stage-pill:last-child { border-right:none; }
.stage-pill.active { background:var(--brand); color:white; }
.stage-pill.past { background:var(--brand-light); color:var(--brand); }
.timeline { margin-top:16px; }
.timeline h4 { font-size:12px; font-weight:700; color:var(--gray); text-transform:uppercase; letter-spacing:1px; margin-bottom:12px; }
.t-item { display:flex; gap:12px; margin-bottom:14px; }
.t-dot { width:10px; height:10px; border-radius:50%; margin-top:3px; flex-shrink:0; }
.t-text { font-size:13px; color:var(--dark); }
.t-time { font-size:11px; color:var(--gray); margin-top:2px; }
.quick-actions { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:20px; }
.qa-btn { padding:8px 16px; border:1px solid var(--border); border-radius:8px; background:white; cursor:pointer; font-size:12px; font-weight:600; color:var(--dark); }
.qa-btn:hover { border-color:var(--brand); color:var(--brand); }

/* REPORTS */
.report-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.chart-bar { margin-bottom:12px; }
.bar-label { display:flex; justify-content:space-between; font-size:12px; margin-bottom:4px; }
.bar-track { background:#F0F0EC; border-radius:4px; height:12px; overflow:hidden; }
.bar-fill { height:100%; border-radius:4px; background:var(--brand); }
.donut-wrap { display:flex; flex-direction:column; align-items:flex-start; width:100%; }
.legend-item { display:flex; align-items:center; gap:8px; font-size:13px; margin-bottom:8px; width:100%; }
.legend-dot { width:12px; height:12px; border-radius:50%; flex-shrink:0; }

/* TASKS */
.task-item { display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--border); }
.task-cb { width:18px; height:18px; border-radius:4px; border:1.5px solid #CCC; cursor:pointer; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.task-cb.done { background:var(--brand); border-color:var(--brand); color:white; font-size:11px; }
.task-text { flex:1; font-size:13px; }
.task-text.done { text-decoration:line-through; color:var(--gray); }
.task-due { font-size:11px; padding:3px 8px; border-radius:10px; }
.due-today { background:#FEF3E2; color:#D4800A; }
.due-over { background:#FDEEEE; color:#C0392B; }
.due-ok { background:#F0F0EC; color:var(--gray); }
.task-sub { font-size:11px; color:var(--brand); margin-top:2px; }

.role-badge { font-size:10px; font-weight:700; padding:3px 9px; border-radius:10px; text-transform:uppercase; }
.role-admin { background:#FDEEEE; color:#C0392B; }
.role-manager { background:#FEF3E2; color:#D4800A; }
.role-sales_rep { background:var(--brand-pale); color:var(--brand); }

/* ===================== TOAST NOTIFICATIONS ===================== */
#toastContainer { position:fixed; top:70px; right:20px; z-index:3000; display:flex; flex-direction:column; gap:10px; max-width:360px; }
.toast { background:white; border-radius:10px; padding:14px 16px; box-shadow:0 8px 30px rgba(0,0,0,0.18); display:flex; align-items:flex-start; gap:10px; font-size:13px; border-left:4px solid var(--brand); animation:toastIn 0.25s ease-out; }
.toast.success { border-left-color:#1B6B4A; }
.toast.error { border-left-color:#C0392B; }
.toast.info { border-left-color:#D4800A; }
.toast-icon { font-size:16px; line-height:1; flex-shrink:0; }
.toast-text { flex:1; color:var(--dark); line-height:1.4; }
.toast-close { cursor:pointer; color:var(--gray); font-size:14px; flex-shrink:0; }
.toast.fade-out { animation:toastOut 0.25s ease-in forwards; }
@keyframes toastIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }
@keyframes toastOut { from{opacity:1;transform:translateX(0)} to{opacity:0;transform:translateX(20px)} }

/* ===================== LOADING BAR ===================== */
#globalLoadingBar { position:fixed; top:0; left:0; height:3px; background:var(--brand-light); z-index:4000; width:0%; transition:width 0.2s ease-out; opacity:0; }
#globalLoadingBar.active { opacity:1; }
.spinner { width:16px; height:16px; border:2px solid rgba(255,255,255,0.3); border-top-color:white; border-radius:50%; display:inline-block; animation:spin 0.6s linear infinite; vertical-align:middle; }
.skeleton { background:linear-gradient(90deg,#F0F0EC 25%,#F8F8F6 50%,#F0F0EC 75%); background-size:200% 100%; animation:shimmer 1.4s infinite; border-radius:6px; }
@keyframes spin { to{transform:rotate(360deg)} }
@keyframes shimmer { from{background-position:200% 0} to{background-position:-200% 0} }

/* ===================== KANBAN DRAG & DROP ===================== */
.stage-cards.drag-over { background:var(--brand-pale); border:2px dashed var(--brand); }
.deal-card[draggable="true"] { cursor:grab; }
.deal-card.dragging { opacity:0.4; }

/* ===================== CALENDAR ===================== */
.calendar-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; background:var(--border); border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.cal-day-header { background:#F8F8F6; padding:8px; text-align:center; font-size:11px; font-weight:700; color:var(--gray); text-transform:uppercase; }
.cal-day { background:white; min-height:90px; padding:6px; font-size:12px; }
.cal-day.other-month { background:#FAFAFA; color:#CCC; }
.cal-day.today { background:var(--brand-pale); }
.cal-day-num { font-weight:700; margin-bottom:4px; }
.cal-task { background:var(--brand); color:white; border-radius:4px; padding:2px 6px; font-size:10px; margin-bottom:2px; cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cal-task.high-priority { background:#C0392B; }
.cal-task.done { background:#9CA3AF; text-decoration:line-through; }
.cal-nav { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; }
.cal-nav button { background:white; border:1px solid #DDD; padding:8px 14px; border-radius:8px; cursor:pointer; font-size:13px; }
.cal-nav button:hover { border-color:var(--brand); color:var(--brand); }

/* ===================== LEAD SCORE ===================== */
.lead-score { display:inline-flex; align-items:center; gap:4px; font-size:11px; font-weight:700; padding:3px 9px; border-radius:10px; }
.score-hot { background:#FDEEEE; color:#C0392B; }
.score-warm { background:#FEF3E2; color:#D4800A; }
.score-cold { background:#EDF4FB; color:#1A5F8E; }

/* ===================== ADVANCED FILTERS ===================== */
.filters-panel { background:white; border:1px solid var(--border); border-radius:10px; padding:16px; margin-bottom:16px; display:none; }
.filters-panel.open { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; }
.filters-panel .form-group { margin-bottom:0; }
.filter-toggle-btn { padding:8px 14px; border:1px solid #DDD; border-radius:8px; background:white; cursor:pointer; font-size:13px; color:var(--gray); }
.filter-toggle-btn.active { border-color:var(--brand); color:var(--brand); background:var(--brand-pale); }
.active-filter-chip { display:inline-flex; align-items:center; gap:6px; background:var(--brand-pale); color:var(--brand); padding:4px 10px; border-radius:14px; font-size:12px; font-weight:600; margin-right:6px; margin-bottom:6px; }
.active-filter-chip span { cursor:pointer; }

/* ===================== MOBILE ===================== */
.mobile-menu-btn { display:none; background:none; border:none; color:white; font-size:22px; cursor:pointer; padding:4px 8px; }
.mobile-overlay { display:none; position:fixed; inset:56px 0 0 0; background:rgba(0,0,0,0.4); z-index:850; }
.mobile-overlay.active { display:block; }

@media (max-width: 900px) {
  .app { grid-template-columns:1fr; }
  .sidebar { position:fixed; top:56px; left:0; bottom:0; width:240px; z-index:900; transform:translateX(-100%); transition:transform 0.25s ease; }
  .sidebar.mobile-open { transform:translateX(0); box-shadow:4px 0 24px rgba(0,0,0,0.3); }
  .mobile-menu-btn { display:inline-block; }
  .metrics { grid-template-columns:repeat(2,1fr); }
  .dash-grid, .report-grid, .combined-grid { grid-template-columns:1fr; }
  table { display:block; }
  thead { display:none; }
  tbody, tr { display:block; }
  tr { border:1px solid var(--border); border-radius:10px; margin-bottom:10px; padding:10px; background:white; }
  td { display:flex; justify-content:space-between; align-items:center; padding:8px 4px; border-bottom:1px solid #F5F5F3; text-align:right; }
  td:last-child { border-bottom:none; }
  td::before { content:attr(data-label); font-weight:700; color:var(--gray); font-size:11px; text-transform:uppercase; text-align:left; margin-right:12px; flex-shrink:0; }
  .action-btns { flex-wrap:wrap; justify-content:flex-end; }
  .modal { width:94vw; padding:20px; }
  .form-row { grid-template-columns:1fr; }
  .toolbar { flex-direction:column; align-items:stretch; }
  .search-box { max-width:100%; }
  .add-btn { margin-left:0; }
  #toastContainer { right:10px; left:10px; max-width:unset; top:64px; }
  .calendar-grid { font-size:10px; }
  .cal-day { min-height:60px; padding:3px; }
}
@media (max-width: 500px) {
  .metrics { grid-template-columns:1fr; }
  .topbar { padding:0 10px; }
  .tb-date { display:none; }
  .page { padding:14px; }
}

/* ===================== AI ASSIST ===================== */
.ai-assist-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 16px; border: 1.5px solid #7C3AED;
  background: linear-gradient(135deg, #F5F0FF, #EDE9FE);
  color: #5B21B6; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.ai-assist-btn:hover { background: linear-gradient(135deg, #EDE9FE, #DDD6FE); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(124,58,237,0.2); }
.ai-assist-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.ai-assist-btn.loading { animation: pulse-purple 1s infinite; }
@keyframes pulse-purple { 0%,100%{opacity:1} 50%{opacity:0.6} }
.ai-assist-status { font-size: 12px; margin-top: 6px; padding: 6px 10px; border-radius: 6px; display: none; }
.ai-assist-status.loading { display: block; background: #F5F0FF; color: #5B21B6; }
.ai-assist-status.error { display: block; background: #FDEEEE; color: #C0392B; }
.ai-writing-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; display: none; align-items: center; justify-content: center; }
.ai-writing-modal.open { display: flex; }
.ai-writing-card { background: white; border-radius: 16px; padding: 28px; width: 560px; max-width: 94vw; max-height: 85vh; overflow-y: auto; border-top: 4px solid #7C3AED; }
.ai-writing-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: #1A2E3A; display: flex; align-items: center; gap: 8px; }
.ai-writing-card p { font-size: 13px; color: var(--gray); margin-bottom: 16px; }
.ai-result-box { background: #F5F0FF; border: 1px solid #DDD6FE; border-radius: 8px; padding: 14px; font-size: 13px; line-height: 1.7; color: #1A2E3A; white-space: pre-wrap; margin-bottom: 16px; min-height: 80px; }
.ai-tone-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.ai-tone-btn { padding: 6px 14px; border: 1px solid #DDD; border-radius: 20px; background: white; cursor: pointer; font-size: 12px; color: var(--gray); transition: all 0.15s; }
.ai-tone-btn.active, .ai-tone-btn:hover { border-color: #7C3AED; color: #5B21B6; background: #F5F0FF; }
.ai-writing-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn-use-text { background: #7C3AED; color: white; border: none; padding: 10px 22px; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 13px; }
.btn-regenerate { background: white; border: 1.5px solid #7C3AED; color: #7C3AED; padding: 10px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13px; }
.btn-regenerate:hover { background: #F5F0FF; }
