/* ===== Design Tokens ===== */
:root {
    --bg: #f5f5f4;
    --surface: #ffffff;
    --surface-2: #fafaf9;
    --border: #e7e5e4;
    --border-light: #f0efee;
    --text: #1c1917;
    --text-secondary: #78716c;
    --text-tertiary: #a8a29e;
    --accent: #1c1917;
    --accent-hover: #44403c;
    --accent-soft: #f5f5f4;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #16a34a;
    --success-soft: #f0fdf4;
    --warning: #ca8a04;
    --warning-soft: #fefce8;
    --info: #2563eb;
    --info-soft: #eff6ff;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.06);
    --font: 'Vazirmatn', system-ui, sans-serif;
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --transition: .18s ease;

    --color-done: #16a34a;
    --color-urgent: #dc2626;
    --color-important: #ca8a04;
    --color-meeting: #2563eb;
    --color-pending: #a8a29e;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c0a09;
    --surface: #1c1917;
    --surface-2: #292524;
    --border: #44403c;
    --border-light: #353330;
    --text: #fafaf9;
    --text-secondary: #a8a29e;
    --text-tertiary: #78716c;
    --accent: #fafaf9;
    --accent-hover: #e7e5e4;
    --accent-soft: #292524;
    --danger-soft: #450a0a;
    --success-soft: #052e16;
    --warning-soft: #422006;
    --info-soft: #172554;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,.35);
}

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

html {
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

/* Buttons/inputs ignore body font unless set explicitly */
button,
input,
select,
textarea,
optgroup {
    font-family: var(--font);
}

a { color: inherit; text-decoration: none; }

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

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

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

.sidebar-brand-row {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
}

.sidebar-brand-text { min-width: 0; flex: 1; }

.sidebar-brand-text a {
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--text);
    display: block;
}

.sidebar-brand-text > span {
    display: block;
    font-size: .72rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.app-logo {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    color: inherit;
}

.app-logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    display: block;
}

.sidebar-logo-mark .app-logo-mark {
    width: 36px;
    height: 36px;
}

.app-logo-text strong {
    display: block;
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.app-logo-text small {
    display: block;
    font-size: .72rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.topbar-logo-mark {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    vertical-align: middle;
}

.topbar-brand-mobile {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-weight: 600;
    font-size: .88rem;
}

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

.nav-section-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-tertiary);
    padding: .75rem .75rem .35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 450;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--accent-soft);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
    font-weight: 500;
}

.nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .4;
    flex-shrink: 0;
}

.nav-item.active .nav-dot { opacity: 1; background: #fff; }

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

.user-card {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info-name {
    font-size: .82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-info-role { font-size: .72rem; color: var(--text-tertiary); }

.app-main {
    flex: 1;
    margin-right: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    width: calc(100% - var(--sidebar-w));
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
    color: var(--text-secondary);
    font-family: var(--font);
}

.topbar-search {
    flex: 1;
    min-width: 0;
    position: relative;
}

.topbar-search input {
    width: 100%;
    padding: .5rem .85rem;
    padding-left: 2rem;
    padding-right: 4.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .85rem;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--text-tertiary);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.topbar-search input::placeholder { color: var(--text-tertiary); }

.search-icon {
    position: absolute;
    left: .7rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--text-tertiary);
    border-radius: 50%;
    pointer-events: none;
}

.search-icon::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 1.5px;
    background: var(--text-tertiary);
    bottom: -2px;
    left: -1px;
    transform: rotate(45deg);
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 300;
    max-height: 320px;
    overflow-y: auto;
}

.search-results.active { display: block; }

.search-result-item {
    display: block;
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-2); }
.search-result-item strong { display: block; font-size: .85rem; font-weight: 500; }
.search-result-item small { color: var(--text-tertiary); font-size: .75rem; }

.topbar-actions { display: flex; align-items: center; gap: .5rem; margin-right: auto; }

.page-content {
    flex: 1;
    width: 100%;
    padding: clamp(1rem, 2.5vw, 2rem) clamp(1rem, 3vw, 2.5rem);
    animation: pageIn .22s ease;
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
}

/* ===== Auth Layout ===== */
.auth-layout { min-height: 100vh; display: flex; }

.auth-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    width: 100%;
}

.auth-panel-left {
    background: var(--accent);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
}

.auth-panel-left h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.3;
    margin-bottom: 1rem;
}

.auth-panel-left p {
    font-size: .95rem;
    opacity: .7;
    line-height: 1.7;
    max-width: 360px;
}

.auth-panel-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.login-form-wrap {
    width: 100%;
    max-width: 380px;
}

.login-form-wrap h2 {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -.02em;
    margin-bottom: .35rem;
}

.login-form-wrap > p {
    color: var(--text-secondary);
    font-size: .875rem;
    margin-bottom: 2rem;
}

/* ===== Typography ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -.025em;
    line-height: 1.3;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: .875rem;
    margin-top: .25rem;
}

.text-muted { color: var(--text-secondary); }
.text-sm { font-size: .82rem; }

.section-title {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-tertiary);
    margin-bottom: .75rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .84rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

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

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-xs { padding: .15rem .45rem; font-size: .72rem; line-height: 1.2; min-height: 0; }
.btn-block { width: 100%; }

.ui-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
}
.ui-icon-sm { width: 14px; height: 14px; }
.ui-icon-md { width: 18px; height: 18px; }

.btn-icon-only,
.btn.btn-icon-only {
    gap: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0;
}
.btn-icon-only.btn-sm {
    width: 32px;
    height: 32px;
    min-width: 32px;
}

.btn-icon-only.btn-block {
    width: 100%;
    min-width: 0;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-size: .9rem;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon .ui-icon { width: 16px; height: 16px; }

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font);
    font-size: .78rem;
    padding: 0;
    transition: color var(--transition);
}
.btn-link:hover { color: var(--text); }
.btn-link.danger:hover { color: var(--danger); }

.btn-link-icon {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.btn-link-icon .ui-icon { width: 14px; height: 14px; }
.btn-link-icon-only {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    justify-content: center;
}
.btn-link-icon-only:hover { background: var(--surface-2); }

/* ===== Forms ===== */
.form-input, .form-select, .form-textarea, .search-input-large {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .875rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--text-tertiary);
    box-shadow: 0 0 0 3px rgba(28,25,23,.06);
}

.form-group { margin-bottom: 1.1rem; }
.form-group label {
    display: block;
    margin-bottom: .4rem;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.field-error { color: var(--danger); font-size: .78rem; margin-top: .25rem; display: block; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.5rem; }
.checkbox-group { display: flex; align-items: center; gap: .5rem; }
.checkbox-group label { margin: 0; }

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 2vw, 1.25rem);
    min-width: 0;
}

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

.card-header h2, .card h2 {
    font-size: .9rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.card-wide { grid-column: 1 / -1; }

.link {
    font-size: .8rem;
    color: var(--text-secondary);
    transition: color var(--transition);
}
.link:hover { color: var(--text); }

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
    gap: clamp(.5rem, 1.5vw, .85rem);
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    transition: box-shadow var(--transition), border-color var(--transition);
}
.stat-link:hover {
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow-sm);
}

.stat-number {
    display: block;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -.03em;
    line-height: 1;
    margin-bottom: .3rem;
}

.stat-label {
    font-size: .75rem;
    color: var(--text-tertiary);
    font-weight: 450;
}

.stat-done .stat-number { color: var(--success); }
.stat-pending .stat-number { color: var(--danger); }

/* ===== Dashboard ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: clamp(.65rem, 1.5vw, 1rem);
}

.schedule-list { display: flex; flex-direction: column; gap: 1px; }

.schedule-item {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .65rem .5rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    border-right: 2px solid transparent;
}

.schedule-item:hover { background: var(--surface-2); }
.schedule-item.color-done { border-right-color: var(--color-done); }
.schedule-item.color-urgent { border-right-color: var(--color-urgent); }
.schedule-item.color-important { border-right-color: var(--color-important); }
.schedule-item.color-meeting { border-right-color: var(--color-meeting); }
.schedule-item.color-pending { border-right-color: var(--color-pending); }
.schedule-item.item-done { opacity: .5; }
.schedule-item.item-done .schedule-info a { text-decoration: line-through; }
.schedule-item.item-overdue { background: var(--danger-soft); }

.schedule-time {
    font-size: .82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    min-width: 42px;
    direction: ltr;
    text-align: left;
}

.schedule-info { flex: 1; min-width: 0; }
.schedule-info a {
    font-size: .875rem;
    font-weight: 450;
    color: var(--text);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.schedule-info a:hover { color: var(--text-secondary); }

.status-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}
.status-btn:hover { border-color: var(--success); }
.status-done { background: var(--success); border-color: var(--success); }

/* ===== Badges & Status ===== */
.badge {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.badge-urgent { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-important { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-normal { background: var(--surface-2); color: var(--text-tertiary); border-color: transparent; }

.status-label {
    font-size: .72rem;
    font-weight: 500;
    padding: .1rem .45rem;
    border-radius: 4px;
}
.status-done { background: var(--success-soft); color: var(--success); }
.status-planned { background: var(--info-soft); color: var(--info); }
.status-cancelled { background: var(--surface-2); color: var(--text-tertiary); }
.status-in_progress { background: var(--warning-soft); color: var(--warning); }
.status-postponed { background: #fdf4ff; color: #9333ea; }

/* ===== Activity ===== */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .75rem;
    align-items: center;
    padding: .65rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: .84rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-user { font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; }
.activity-action { color: var(--text-secondary); }
.activity-time { color: var(--text-tertiary); font-size: .78rem; white-space: nowrap; }

.empty-state {
    color: var(--text-tertiary);
    font-size: .85rem;
    padding: 1.5rem .5rem;
    text-align: center;
}

.empty-state-large {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}
.empty-state-large p { margin-bottom: 1.25rem; }

/* ===== Calendar ===== */
.calendar-page {
    width: 100%;
    max-width: none;
}

.page-content:has(.dash-page) {
    padding: .85rem clamp(.85rem, 2vw, 1.25rem) 1rem;
}

.page-content:has(.calendar-page) {
    padding: clamp(.65rem, 1.5vw, 1.25rem) clamp(.5rem, 1.2vw, 1rem);
}

.calendar-controls { display: flex; gap: .75rem; align-items: center; }

.view-tabs {
    display: flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.view-tabs .tab {
    padding: .35rem .85rem;
    border-radius: 4px;
    font-family: var(--font);
    font-size: .82rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.view-tabs .tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    font-weight: 500;
}

.month-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.month-header h2 {
    font-size: 1rem;
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

.month-grid {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: calc(100vh - 220px);
    display: flex;
    flex-direction: column;
}

.month-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}

.month-weekdays span {
    text-align: center;
    padding: .6rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: .04em;
}

.month-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    flex: 1;
    min-height: 0;
}

.month-day {
    min-height: clamp(110px, 16vh, 200px);
    border: 1px solid var(--border-light);
    padding: .35rem .4rem .45rem;
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.month-day:hover { background: var(--surface-2); }
.month-day.today { background: var(--accent-soft); }
.month-day.today .day-number { background: var(--accent); color: #fff; }
.month-day.empty { background: var(--bg); cursor: default; }

.day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 500;
}

.day-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: .25rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

.month-event {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: .72rem;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    font-weight: 450;
    flex-shrink: 0;
}
.month-event .ev-time {
    font-size: .65rem;
    opacity: .85;
    direction: ltr;
    flex-shrink: 0;
    margin-left: 3px;
}
.month-event a {
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    flex: 1;
    min-width: 0;
}
.month-event .drag-handle { font-size: .6rem; padding: 0; }

.month-event.color-done { background: var(--success-soft); color: var(--success); }
.month-event.color-urgent { background: var(--danger-soft); color: var(--danger); }
.month-event.color-important { background: var(--warning-soft); color: var(--warning); }
.month-event.color-meeting { background: var(--info-soft); color: var(--info); }
.month-event.color-pending { background: var(--surface-2); color: var(--text-secondary); }

.more-events {
    display: block;
    font-size: .68rem;
    color: var(--accent);
    padding: 2px 4px;
    margin-top: 2px;
    text-decoration: none;
    flex-shrink: 0;
}
.more-events:hover { text-decoration: underline; }

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: clamp(.35rem, .8vw, .65rem);
    min-height: calc(100vh - 220px);
}
.week-column {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: clamp(280px, 55vh, 520px);
    display: flex;
    flex-direction: column;
}
.week-column.today { border-color: var(--accent); }
.week-day-header {
    padding: .6rem;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    font-size: .78rem;
}
.week-day-header .weekday { display: block; font-weight: 600; color: var(--text-secondary); }
.week-day-header .day-num { color: var(--text-tertiary); }
.week-events {
    padding: .4rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.week-event {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: .35rem .5rem;
    border-radius: 4px;
    font-size: .76rem;
    font-weight: 450;
    flex-shrink: 0;
}
.week-event .ev-time {
    font-size: .68rem;
    opacity: .85;
    direction: ltr;
}
.week-event a { color: inherit; flex: 1; min-width: 0; }
.week-event .drag-handle { font-size: .65rem; padding: 0; }
.week-event.color-done { background: var(--success-soft); color: var(--success); }
.week-event.color-urgent { background: var(--danger-soft); color: var(--danger); }
.week-event.color-important { background: var(--warning-soft); color: var(--warning); }
.week-event.color-meeting { background: var(--info-soft); color: var(--info); }
.week-event.color-pending { background: var(--surface-2); color: var(--text-secondary); }

.week-title { font-size: .875rem; color: var(--text-secondary); margin-bottom: .75rem; text-align: center; }

.color-legend {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    font-size: .75rem;
    color: var(--text-tertiary);
}

.legend-item { display: flex; align-items: center; gap: .4rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.color-done { background: var(--color-done); }
.dot.color-urgent { background: var(--color-urgent); }
.dot.color-important { background: var(--color-important); }
.dot.color-meeting { background: var(--color-meeting); }
.dot.color-pending { background: var(--color-pending); }

.day-timeline { display: flex; flex-direction: column; gap: .5rem; }

.timeline-event {
    display: flex;
    gap: .85rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-right: 3px solid var(--color-pending);
}

.timeline-event.color-done { border-right-color: var(--color-done); }
.timeline-event.color-urgent { border-right-color: var(--color-urgent); }
.timeline-event.color-important { border-right-color: var(--color-important); }
.timeline-event.color-meeting { border-right-color: var(--color-meeting); }

.timeline-time { font-weight: 600; font-size: .85rem; direction: ltr; color: var(--text-secondary); }
.timeline-body a { font-weight: 500; font-size: .875rem; }
.timeline-body a:hover { color: var(--text-secondary); }

/* ===== Daily Timeline ===== */
.date-nav { display: flex; align-items: center; gap: 1rem; }

.daily-timeline { display: flex; flex-direction: column; }

.timeline-row {
    display: flex;
    gap: 1.25rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.timeline-row::before {
    content: '';
    position: absolute;
    right: 52px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
}

.timeline-row:last-child::before { bottom: 50%; }
.timeline-row:first-child::before { top: 50%; }

.timeline-time-col {
    font-size: .85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 44px;
    direction: ltr;
    text-align: left;
    color: var(--text-secondary);
    padding-top: .1rem;
}

.timeline-content-col { flex: 1; }
.timeline-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    margin-bottom: .5rem;
}

.timeline-row.color-done .timeline-card { border-right: 2px solid var(--color-done); }
.timeline-row.color-urgent .timeline-card { border-right: 2px solid var(--color-urgent); }
.timeline-row.color-important .timeline-card { border-right: 2px solid var(--color-important); }
.timeline-row.color-meeting .timeline-card { border-right: 2px solid var(--color-meeting); }
.timeline-row.row-done { opacity: .45; }
.timeline-row.row-overdue .timeline-card { background: var(--danger-soft); border-color: #fecaca; }

.timeline-card-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.timeline-title { font-weight: 500; font-size: .9rem; }
.timeline-title:hover { color: var(--text-secondary); }
.timeline-meta { display: flex; gap: .65rem; font-size: .78rem; color: var(--text-tertiary); margin-top: .35rem; flex-wrap: wrap; }
.timeline-desc { font-size: .82rem; color: var(--text-secondary); margin-top: .5rem; line-height: 1.5; }

/* ===== Weekly Schedule ===== */
.weekly-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: clamp(.4rem, 1vw, .75rem);
}

.weekly-day-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 160px;
}

.weekly-day-header {
    padding: .65rem;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
    flex-shrink: 0;
}

.weekly-day-header .weekday { display: block; font-size: .82rem; font-weight: 600; }
.weekly-day-header .date { font-size: .72rem; color: var(--text-tertiary); margin-top: 1px; }

.weekly-events {
    position: relative;
    padding: .4rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-height: 120px;
}

.weekly-events.drop-zone.drag-over {
    background: var(--info-soft);
    outline: 2px dashed var(--info);
    outline-offset: -3px;
}

.weekly-drop-empty {
    position: absolute;
    inset: .15rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .5rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), background var(--transition);
    z-index: 1;
}

.weekly-events.drag-over .weekly-drop-empty {
    border-color: var(--info);
    background: rgba(255, 255, 255, .5);
}

.weekly-drop-hint {
    display: none;
    font-size: .72rem;
    font-weight: 600;
    color: var(--info);
}

.weekly-events.drag-over .weekly-drop-hint {
    display: block;
}

.weekly-drop-empty .weekly-drop-hint {
    display: block;
    color: var(--text-tertiary);
    font-weight: 500;
}

.weekly-events.drag-over .weekly-drop-empty .weekly-drop-hint {
    color: var(--info);
    font-weight: 600;
}

body.is-dragging-event .weekly-day-header,
body.is-dragging-event .weekly-event-link,
body.is-dragging-event .add-day-link,
body.is-dragging-event .event-actions {
    pointer-events: none;
}

body.is-dragging-event .weekly-events.drop-zone {
    z-index: 2;
}

body.is-dragging-event .drag-handle,
body.is-dragging-event .event-draggable {
    pointer-events: auto;
}

.weekly-event {
    display: flex;
    align-items: flex-start;
    gap: .15rem;
    padding: .35rem .5rem;
    border-radius: 4px;
    font-size: .78rem;
    border-right: 2px solid var(--color-pending);
    cursor: grab;
}
.weekly-event:active { cursor: grabbing; }
.weekly-event-link {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.weekly-event.color-done { border-right-color: var(--color-done); background: var(--success-soft); }
.weekly-event.color-urgent { border-right-color: var(--color-urgent); background: var(--danger-soft); }
.weekly-event.color-important { border-right-color: var(--color-important); background: var(--warning-soft); }
.weekly-event.color-meeting { border-right-color: var(--color-meeting); background: var(--info-soft); }

.weekly-event .time { font-size: .7rem; color: var(--text-tertiary); direction: ltr; }
.weekly-event .title { font-weight: 450; }

/* ===== Events List ===== */
.filter-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: clamp(.65rem, 1.5vw, .85rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    align-items: center;
}

.filter-bar .form-input,
.filter-bar .form-select,
.filter-bar .search-input {
    flex: 1 1 140px;
    min-width: 120px;
    font-size: .82rem;
    padding: .45rem .65rem;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.event-list { display: flex; flex-direction: column; gap: .4rem; }

.event-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-right: 2px solid var(--color-pending);
    transition: box-shadow var(--transition);
}

.event-row:hover { box-shadow: var(--shadow-xs); }
.event-row.color-done { border-right-color: var(--color-done); }
.event-row.color-urgent { border-right-color: var(--color-urgent); }
.event-row.color-important { border-right-color: var(--color-important); }
.event-row.color-meeting { border-right-color: var(--color-meeting); }

.event-day { font-weight: 600; font-size: .85rem; direction: ltr; color: var(--text-secondary); min-width: 44px; }
.event-info { flex: 1; min-width: 0; }
.event-title { font-weight: 500; font-size: .875rem; display: block; margin-bottom: .2rem; }
.event-title:hover { color: var(--text-secondary); }
.event-meta { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ===== Detail ===== */
.event-detail-hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    padding: clamp(1.1rem, 3vw, 1.6rem);
    margin-bottom: 1rem;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .13), transparent 32%),
        linear-gradient(135deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border);
    border-right: 4px solid var(--color-pending);
    border-radius: calc(var(--radius-lg) + 4px);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.event-detail-hero::after {
    content: '';
    position: absolute;
    inset: auto auto -56px -56px;
    width: 150px;
    height: 150px;
    border-radius: 999px;
    background: var(--accent-soft);
    opacity: .75;
    pointer-events: none;
}

.event-detail-hero.color-done { border-right-color: var(--color-done); }
.event-detail-hero.color-urgent { border-right-color: var(--color-urgent); }
.event-detail-hero.color-important { border-right-color: var(--color-important); }
.event-detail-hero.color-meeting { border-right-color: var(--color-meeting); }
.event-detail-hero.is-done { opacity: .85; }

.event-detail-hero-main,
.event-detail-actions {
    position: relative;
    z-index: 1;
}

.event-detail-kicker {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
    margin-bottom: .45rem;
    color: var(--text-secondary);
    font-size: .8rem;
    font-weight: 500;
}

.event-detail-dot {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--text-tertiary);
}

.event-detail-hero h1 {
    max-width: 820px;
    font-size: clamp(1.25rem, 3.5vw, 2rem);
    line-height: 1.35;
    letter-spacing: -.03em;
}

.event-detail-description {
    max-width: 760px;
    margin-top: .65rem;
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-line;
}

.event-detail-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.event-detail-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .65rem;
    margin-bottom: 1rem;
}

.event-summary-card {
    min-width: 0;
    padding: .85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.event-summary-label {
    display: block;
    margin-bottom: .25rem;
    color: var(--text-tertiary);
    font-size: .74rem;
}

.event-summary-card strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: .92rem;
    font-weight: 600;
}

.detail-top-bar {
    margin-bottom: 1rem;
}

.event-status-panel {
    justify-content: space-between;
    padding: .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.event-status-title {
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 600;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
    gap: clamp(.65rem, 1.5vw, 1rem);
    align-items: start;
}

.detail-card {
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition), transform var(--transition);
}

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

.event-info-card {
    grid-row: span 2;
}

.detail-list {
    display: grid;
    grid-template-columns: minmax(86px, auto) minmax(0, 1fr);
    gap: .65rem .9rem;
    font-size: .84rem;
    margin-top: .75rem;
}

.detail-list dt { color: var(--text-tertiary); font-weight: 450; }
.detail-list dd {
    min-width: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

.detail-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 .45rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-tertiary);
    font-size: .72rem;
    font-weight: 600;
}

.notes-list, .files-list, .reminders-list, .history-list { margin-top: .75rem; }

.note-item {
    padding: .75rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin-bottom: .4rem;
    border: 1px solid var(--border-light);
}

.note-item p { font-size: .875rem; line-height: 1.55; }
.note-meta {
    display: flex;
    gap: .65rem;
    font-size: .75rem;
    color: var(--text-tertiary);
    margin-top: .4rem;
    align-items: center;
    flex-wrap: wrap;
}

.file-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 1;
    min-width: 0;
    padding: .55rem .75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: .84rem;
    color: var(--text);
    transition: background var(--transition);
    overflow-wrap: anywhere;
}

.file-item:hover { background: var(--border-light); }
.file-item::before { content: ''; width: 6px; height: 6px; background: var(--text-tertiary); border-radius: 1px; flex-shrink: 0; }

.reminder-item, .history-item {
    display: flex;
    gap: .75rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: .82rem;
    flex-wrap: wrap;
    align-items: center;
}

.reminder-item:last-child, .history-item:last-child { border-bottom: none; }

.inline-form { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .75rem; }
.inline-form textarea { flex: 1 1 220px; min-width: 0; }

.danger-zone {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
}
.header-actions { display: flex; gap: .4rem; }

@media (max-width: 900px) {
    .event-detail-hero {
        grid-template-columns: 1fr;
    }
    .event-detail-actions {
        justify-content: stretch;
    }
    .event-detail-actions .btn {
        flex: 1;
    }
    .event-detail-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .event-info-card {
        grid-row: auto;
    }
}

@media (max-width: 600px) {
    .event-detail-summary {
        grid-template-columns: 1fr;
    }
    .event-status-panel,
    .status-form-inline {
        align-items: stretch;
    }
    .event-status-panel .form-select,
    .event-status-panel .btn {
        width: 100%;
    }
    .detail-list {
        grid-template-columns: 1fr;
        gap: .2rem;
    }
    .detail-list dd {
        margin-bottom: .45rem;
    }
    .file-row {
        align-items: stretch;
        flex-direction: column;
    }
}

.form-card { max-width: 560px; }

/* ===== Reports ===== */
.type-chart { display: flex; flex-direction: column; gap: .65rem; margin-top: .75rem; }

.type-bar { display: flex; align-items: center; gap: .75rem; }
.type-label { min-width: 70px; font-size: .82rem; color: var(--text-secondary); }
.bar-track { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.type-count { font-size: .82rem; font-weight: 600; min-width: 24px; text-align: left; direction: ltr; }

/* ===== Table ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.data-table th, .data-table td { padding: .65rem .85rem; text-align: right; border-bottom: 1px solid var(--border-light); }
.data-table th { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); background: var(--surface-2); }
.data-table tr:hover td { background: var(--surface-2); }
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Settings ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
    gap: clamp(.65rem, 1.5vw, 1rem);
}

/* ===== Messages ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    pointer-events: none;
}

.alert {
    padding: .6rem 1.1rem;
    border-radius: var(--radius);
    font-size: .84rem;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: slideDown .25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }

/* ===== Modal & FAB ===== */
.floating-actions {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    z-index: 185;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .5rem;
}

.floating-actions .fab,
.floating-actions .team-msg-fab {
    position: static;
}

.fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-family: var(--font);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
    z-index: 90;
    border: none;
    transition: transform var(--transition), box-shadow var(--transition);
    line-height: 1;
    padding: 0;
}
.fab .ui-icon { width: 20px; height: 20px; }

.fab:hover { transform: scale(1.05); box-shadow: 0 6px 24px rgba(0,0,0,.15); }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active { display: flex; }

.modal-dialog {
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    animation: modalIn .22s ease;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 0;
    width: 100%;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.25rem .75rem;
    border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-subtitle { font-size: .75rem; color: var(--text-tertiary); margin-top: .2rem; }
.modal-subtitle kbd {
    font-family: var(--font);
    font-size: .65rem;
    padding: .1rem .3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface-2);
}

.modal-body { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.modal-footer {
    padding: .75rem 1.25rem 1.25rem;
    border-top: 1px solid var(--border-light);
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

.modal-close {
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 1.35rem;
    cursor: pointer;
    color: var(--text-tertiary);
    line-height: 1;
    padding: .2rem;
    flex-shrink: 0;
}
.modal-close:hover { color: var(--text); }

body.modal-open { overflow: hidden; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
    .form-row-2 { grid-template-columns: 1fr; }
    .modal { padding: .75rem; align-items: flex-end; }
    .modal-dialog { max-height: 92vh; }
}

.search-page-form { display: flex; gap: .6rem; margin-bottom: 1.5rem; }
.search-input-large { flex: 1; font-size: .9rem; padding: .65rem 1rem; }

/* ===== Overlay ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 199;
}

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

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .weekly-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .week-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .app-main {
        margin-right: 0;
        width: 100%;
    }
    .sidebar-toggle { display: flex; }
    .auth-split { grid-template-columns: 1fr; }
    .auth-panel-left { display: none; }
    .weekly-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { gap: .65rem; flex-wrap: wrap; height: auto; min-height: var(--topbar-h); padding: .65rem 1rem; }
    .topbar-search { order: 3; flex: 1 1 100%; }
    .calendar-controls { flex-wrap: wrap; width: 100%; }
}

@media (max-width: 600px) {
    .topbar { padding: .65rem .85rem; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .month-day { min-height: 100px; }
    .month-grid { min-height: auto; }
    .week-grid { min-height: auto; }
    .week-column { min-height: 200px; }
    .weekly-grid,
    .week-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-input,
    .filter-bar .form-select,
    .filter-bar .search-input { width: 100%; min-width: 0; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .btn,
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1; }
    .date-nav { width: 100%; justify-content: space-between; }
    .event-row { flex-wrap: wrap; gap: .65rem; }
    .floating-actions .fab { width: 44px; height: 44px; font-size: 1.25rem; }
    .data-table { font-size: .78rem; }
    .data-table th, .data-table td { padding: .5rem .6rem; }
}

@media (min-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .dashboard-grid .card-wide {
        grid-column: 1 / -1;
    }
}

/* ===== New components ===== */
.chip-bar { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
    padding: .35rem .75rem;
    border-radius: 999px;
    font-family: var(--font);
    font-size: .8rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    transition: all var(--transition);
}
.chip:hover, .chip.active { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

.progress-wrap { margin-bottom: 1.25rem; }
.progress-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-secondary); margin-bottom: .35rem; }
.progress-track { height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width .4s ease; }

.count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; font-size: .7rem; font-weight: 600;
    background: var(--surface-2); color: var(--text-tertiary); margin-right: .35rem;
}

.stat-link { text-decoration: none; color: inherit; transition: box-shadow var(--transition); }
.stat-link:hover { box-shadow: var(--shadow-sm); }

.item-meta { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .25rem; align-items: center; }
.meta-user { font-size: .72rem; color: var(--text-tertiary); }

.calendar-nav-bar {
    display: flex; align-items: center; justify-content: center; gap: .75rem;
    margin-bottom: 1rem; flex-wrap: wrap;
}
.calendar-nav-title { font-weight: 600; font-size: .95rem; min-width: 160px; text-align: center; }

.weekly-day-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.weekly-day-card.is-today { border-color: var(--accent); box-shadow: var(--shadow-xs); }
.weekly-day-header { display: block; padding: .65rem; border-bottom: 1px solid var(--border-light); text-align: center; color: inherit; }
.weekly-day-header:hover { background: var(--surface-2); text-decoration: none; }
.add-day-link {
    display: block;
    width: 100%;
    text-align: center;
    font-family: var(--font);
    font-size: .75rem;
    color: var(--text-tertiary);
    padding: .5rem;
    background: none;
    border: none;
    cursor: pointer;
}
.add-day-link:hover { color: var(--text); background: var(--surface-2); border-radius: var(--radius-sm); }

.event-date-col { min-width: 72px; }
.event-jalali { display: block; font-size: .78rem; font-weight: 600; }
.event-day { display: block; font-size: .82rem; color: var(--text-secondary); direction: ltr; text-align: left; }

.status-form-inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.status-form-inline .form-select { min-width: 160px; }

.form-card-wide { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-group-wide { grid-column: 1 / -1; }
.field-hint { display: block; font-size: .75rem; color: var(--text-tertiary); margin-top: .3rem; }
.quick-add-parse-hint {
    color: var(--info);
    font-size: .72rem;
}

.file-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.note-delete-form { margin-top: .25rem; }
.custom-minutes-wrap { display: none; }

.backup-list { list-style: none; margin-top: .5rem; }
.backup-list li { padding: .35rem 0; border-bottom: 1px solid var(--border-light); font-size: .84rem; }

.show-mobile-fab { display: flex; }
.hide-mobile-fab {}

@media (max-width: 900px) {
    .hide-mobile-fab { display: none !important; }
    .floating-actions .fab { width: 48px; height: 48px; }
}

@media (min-width: 901px) {
    .floating-actions .fab { display: flex; }
}

/* ===== Jalali Date Picker ===== */
.jalali-date-input { cursor: pointer; }
.jalali-picker-popover {
    position: absolute;
    z-index: 500;
    width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: .75rem;
    display: none;
}
.jalali-picker-popover.active { display: block; }
.jp-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .65rem;
}
.jp-title { font-weight: 600; font-size: .88rem; }
.jp-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr);
    text-align: center; font-size: .68rem; color: var(--text-tertiary);
    margin-bottom: .35rem;
}
.jp-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.jp-day {
    border: none; background: transparent; border-radius: var(--radius-sm);
    padding: .4rem 0; font-size: .82rem; cursor: pointer;
    font-family: var(--font); color: var(--text);
}
.jp-day:hover { background: var(--surface-2); }
.jp-day.is-today { background: var(--accent); color: #fff; font-weight: 600; }
.jp-footer { margin-top: .5rem; text-align: center; }
.jp-status {
    grid-column: 1 / -1;
    text-align: center;
    font-size: .78rem;
    color: var(--text-tertiary);
    padding: 1rem .5rem;
    margin: 0;
}

/* ===== Backup list ===== */
.backup-create-form { margin: .75rem 0; }
.backup-item {
    display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
    padding: .65rem 0; border-bottom: 1px solid var(--border-light);
}
.backup-info { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.backup-meta { font-size: .72rem; color: var(--text-tertiary); }
.backup-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.ltr-cell { direction: ltr; text-align: right; }

/* ===== Reports ===== */
.stats-grid-8 { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

/* ===== Drag & drop ===== */
.drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    font-size: .9rem;
    padding: 0 .25rem;
    user-select: none;
    flex-shrink: 0;
    opacity: .5;
    transition: opacity var(--transition);
}
.event-draggable:hover .drag-handle,
.drag-handle:hover { opacity: 1; color: var(--text-secondary); }
.event-draggable.is-dragging { opacity: .45; }
.drop-zone.drag-over {
    background: var(--info-soft) !important;
    outline: 2px dashed var(--info);
    outline-offset: -2px;
}
.drop-zone.drop-loading { opacity: .6; pointer-events: none; }
.month-day.drag-over,
.weekly-events.drag-over,
.week-column.drag-over { background: var(--info-soft) !important; }
.drag-hint-inline { font-size: .75rem; color: var(--text-tertiary); margin-right: auto; }
.add-day-link {
    display: block;
    width: 100%;
    text-align: center;
    font-size: .75rem;
    color: var(--text-tertiary);
    padding: .5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
}
.add-day-link:hover { color: var(--text); background: var(--surface-2); }
.calendar-drag-hint { font-size: .75rem; color: var(--text-tertiary); margin-top: .5rem; }

.calendar-page .day-timeline {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: calc(100vh - 220px);
}
.calendar-page .day-timeline .timeline-event {
    padding: .75rem 1rem;
}
.calendar-page .color-legend {
    margin-top: 1rem;
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
}
.weekly-event .drag-handle { font-size: .7rem; margin-left: .15rem; }
.timeline-row { display: flex; align-items: flex-start; gap: .35rem; }

.header-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }

/* ===== Empty states ===== */
.empty-state-block {
    text-align: center;
    padding: 2rem 1rem;
}
.empty-state-block.compact { padding: 1.25rem .5rem; }
.empty-state-title {
    color: var(--text-secondary);
    font-size: .88rem;
    margin-bottom: .65rem;
}
.empty-state-desc {
    color: var(--text-tertiary);
    font-size: .8rem;
    margin-bottom: .75rem;
}

/* ===== Pagination ===== */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
    padding: .75rem;
}
.page-info { font-size: .82rem; color: var(--text-secondary); }

/* ===== Reminders preview (dashboard) ===== */
.reminders-card { margin-bottom: 1.25rem; }
.reminders-preview { display: flex; flex-direction: column; gap: .35rem; }
.reminder-preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    transition: background var(--transition);
}
.reminder-preview-item:hover { background: var(--surface-2); text-decoration: none; }
.reminder-preview-title { font-size: .86rem; font-weight: 500; }
.reminder-preview-time { font-size: .75rem; color: var(--text-tertiary); direction: ltr; }

.reminder-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .45rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: .84rem;
}
.reminder-item:last-child { border-bottom: none; }

.week-date-input { max-width: 130px; }

/* ===== Auth polish ===== */
.login-alert { margin-bottom: 1rem; }
.login-submit { margin-top: .5rem; }
.auth-panel-logo {
    margin-bottom: 1.25rem;
}
.auth-panel-logo .app-logo-mark {
    width: 44px;
    height: 44px;
}
.auth-logo {
    display: none;
    justify-content: center;
    margin-bottom: .75rem;
}
.auth-logo .app-logo-mark {
    width: 40px;
    height: 40px;
}
.auth-mobile-brand {
    display: none;
    font-weight: 600;
    font-size: .95rem;
    margin-bottom: 1rem;
    color: var(--text);
}

/* ===== Loading state ===== */
.btn.is-loading {
    opacity: .7;
    pointer-events: none;
    position: relative;
}
.btn.is-loading::after {
    content: '';
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-right: .5rem;
    display: inline-block;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Focus visible ===== */
.btn:focus-visible,
.nav-item:focus-visible,
.chip:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.jp-day:focus-visible {
    outline: 2px solid var(--info);
    outline-offset: 2px;
}

/* ===== Print ===== */
@media print {
    .sidebar, .topbar, .fab, .sidebar-overlay, .toast-container,
    .filter-bar, .pagination-bar, .btn, .status-btn, .hide-mobile-fab { display: none !important; }
    .app-main { margin: 0 !important; }
    .page-content { padding: 0 !important; }
    body { background: #fff; font-size: 12pt; }
    .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

@media (max-width: 900px) {
    .auth-logo { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    color: var(--text-tertiary);
    margin-bottom: .75rem;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--text); }

/* ===== Day summary ===== */
.day-summary-bar {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding: .65rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .82rem;
    color: var(--text-secondary);
}

.date-jump-form {
    display: flex;
    align-items: center;
    gap: .35rem;
}
.date-jump-form .form-input { width: 120px; padding: .35rem .5rem; font-size: .82rem; }

/* ===== Search kbd hint ===== */
.topbar-search { position: relative; }
.search-kbd {
    position: absolute;
    right: .65rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font);
    font-size: .65rem;
    padding: .1rem .35rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-tertiary);
    background: var(--surface-2);
    pointer-events: none;
}
.topbar-search:focus-within .search-kbd,
.topbar-search input:not(:placeholder-shown) ~ .search-kbd { display: none; }

.note-readonly {
    font-size: .88rem;
    line-height: 1.55;
    white-space: pre-wrap;
    margin-bottom: .35rem;
}

.danger-zone {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

@media (max-width: 900px) {
    .search-kbd { display: none; }
    .topbar-search input { padding-right: .85rem; }
    .date-jump-form .form-input { width: 100px; }
}

/* ===== Theme toggle ===== */
.theme-toggle-btn {
    width: 100%;
    margin-bottom: .65rem;
    padding: .45rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: .78rem;
    cursor: pointer;
    transition: all var(--transition);
}
.theme-toggle-btn:hover {
    background: var(--accent-soft);
    color: var(--text);
}

/* ===== Topbar badge ===== */
.topbar-badge {
    font-size: .72rem;
    font-weight: 500;
    padding: .3rem .65rem;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    white-space: nowrap;
    transition: opacity var(--transition);
}
.topbar-badge:hover { opacity: .85; text-decoration: none; }

/* ===== Profile layout ===== */
.profile-layout {
    display: grid;
    grid-template-columns: minmax(240px, 280px) 1fr;
    gap: 1rem;
    align-items: start;
}
.profile-summary {
    text-align: center;
    padding: 1.5rem 1rem;
}
.user-avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
    margin: 0 auto .75rem;
}
.profile-summary h2 { font-size: 1rem; margin-bottom: .15rem; }
.profile-role { font-size: .78rem; color: var(--text-tertiary); margin-bottom: 1rem; }
.profile-meta {
    text-align: right;
    font-size: .82rem;
    border-top: 1px solid var(--border-light);
    padding-top: .75rem;
}
.profile-meta dt { color: var(--text-tertiary); font-size: .72rem; margin-top: .5rem; }
.profile-meta dd { font-weight: 500; }
.profile-form { margin-top: .75rem; }

.card-flush { padding: 0; overflow: hidden; }
.empty-cell {
    text-align: center;
    color: var(--text-tertiary);
    padding: 2rem !important;
}
.form-errors { margin-bottom: 1rem; }

@media (max-width: 768px) {
    .profile-layout { grid-template-columns: 1fr; }
}

/* ===== Notifications panel ===== */
.notifications-wrap { position: relative; }
.notifications-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}
.notifications-btn:hover { background: var(--surface); color: var(--text); }
.notif-dot {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notifications-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 320px;
    max-width: calc(100vw - 2rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 400;
    overflow: hidden;
}
.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .88rem;
    border-bottom: 1px solid var(--border-light);
}
.notif-panel-actions {
    display: flex;
    gap: .35rem;
    flex-shrink: 0;
}
.notif-action-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.notif-action-btn .ui-icon { width: 14px; height: 14px; }
.notif-action-btn:hover:not(:disabled) {
    background: var(--surface);
    color: var(--text);
}
.notif-action-btn:disabled {
    opacity: .45;
    cursor: default;
}
.notif-action-danger:hover:not(:disabled) {
    color: var(--danger);
    border-color: var(--danger-soft);
    background: var(--danger-soft);
}
.notif-panel-body { max-height: 360px; overflow-y: auto; }
.notif-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.notif-row:hover { background: var(--surface-2); }
.notif-row.is-read { opacity: .72; }
.notif-row .notif-item {
    flex: 1;
    min-width: 0;
    border-bottom: none;
}
.notif-row-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: .35rem .45rem;
    flex-shrink: 0;
}
.notif-row-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font);
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.notif-row-btn .ui-icon { width: 12px; height: 12px; }
.notif-row-btn:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text);
}
.notif-row-btn:disabled {
    opacity: .35;
    cursor: default;
}
.notif-btn-read:hover:not(:disabled) {
    color: var(--success);
    border-color: var(--success-soft);
    background: var(--success-soft);
}
.notif-btn-dismiss:hover:not(:disabled) {
    color: var(--danger);
    border-color: var(--danger-soft);
    background: var(--danger-soft);
}
.notif-item.is-read strong,
.notif-item.is-read span { font-weight: 450; }
.notif-panel-footer {
    display: block;
    text-align: center;
    padding: .65rem;
    font-size: .78rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-light);
    background: var(--surface-2);
}
.notif-panel-footer:hover { color: var(--text); text-decoration: none; }
.notif-item {
    display: block;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item strong { display: block; font-size: .84rem; margin-bottom: .1rem; }
.notif-item small { font-size: .72rem; color: var(--text-tertiary); }
.notif-item.notif-warn strong { color: var(--danger); }
.notif-static { font-size: .82rem; color: var(--text-secondary); }
.notif-section-label {
    padding: .5rem 1rem .25rem;
    font-size: .68rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.notif-empty, .notif-loading {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: .84rem;
}
.hide-mobile { display: inline-flex; }
@media (max-width: 900px) { .hide-mobile { display: none !important; } }

/* ===== User management ===== */
.users-manage-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .75rem; }
.user-manage-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.user-manage-summary {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem .85rem;
    cursor: pointer;
    list-style: none;
    background: var(--surface-2);
    font-family: var(--font);
}
.user-manage-summary::-webkit-details-marker { display: none; }
.user-manage-name { font-weight: 500; font-size: .88rem; }
.user-manage-username { margin-right: auto; font-size: .72rem; color: var(--text-tertiary); direction: ltr; }
.user-manage-form { padding: .85rem; border-top: 1px solid var(--border-light); }
.sidebar-slug { display: block; font-size: .65rem; color: var(--text-tertiary); opacity: .85; margin-top: 2px; }

/* Sidebar logout — text label, not square icon */
.user-card .btn-icon {
    width: auto;
    min-width: 32px;
    height: auto;
    padding: .25rem .5rem;
    font-size: .72rem;
}
.settings-alert { margin-bottom: 1rem; }
.auth-panel-links { margin-top: 1rem; font-size: .85rem; }
.auth-panel-links a { color: rgba(255,255,255,.85); }
.create-user-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}
.create-user-section h3 { font-size: .88rem; margin-bottom: .75rem; }
@media (max-width: 768px) { .form-grid-3 { grid-template-columns: 1fr; } }

/* ===== Event quick actions (tick + note) ===== */
.event-actions {
    display: flex;
    align-items: center;
    gap: .2rem;
    flex-shrink: 0;
    margin-right: auto;
}

.event-actions-compact .event-action-btn,
.event-action-btn {
    min-width: 28px;
    width: 28px;
    height: 28px;
    padding: 0;
}
.event-action-btn .ui-icon { width: 14px; height: 14px; }

.event-check {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s ease;
    padding: 0;
    font-family: var(--font);
}
.event-check:hover {
    border-color: var(--success);
    background: var(--success-soft);
    transform: scale(1.05);
}
.event-check.is-checked {
    background: var(--success);
    border-color: var(--success);
}
.event-check-icon {
    width: 12px;
    height: 7px;
    border: solid #fff;
    border-width: 0 0 2px 2px;
    transform: rotate(-45deg) scale(0);
    margin-top: -3px;
    transition: transform .12s ease;
}
.event-check.is-checked .event-check-icon { transform: rotate(-45deg) scale(1); }

.event-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 .45rem;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: .72rem;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.event-action-btn:hover {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}
.event-action-link { font-weight: 500; }

.is-done-text {
    text-decoration: line-through;
    opacity: .65;
}

.schedule-item,
.event-row,
.timeline-event {
    transition: background var(--transition);
}
.schedule-item:hover,
.event-row:hover {
    background: var(--surface-2);
}

.timeline-card-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.timeline-card-header .timeline-title { flex: 1; min-width: 0; }
.timeline-card-header .event-actions { margin-right: 0; }

.weekly-event {
    flex-wrap: wrap;
    align-items: center;
}
.weekly-event .event-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: .15rem;
    padding-top: .15rem;
    border-top: 1px solid var(--border-light);
}

.month-event {
    flex-wrap: wrap;
    align-items: center;
}
.month-event .event-actions-compact {
    width: 100%;
    justify-content: flex-end;
    margin-top: 1px;
}

.week-event {
    flex-wrap: wrap;
}
.week-event .event-actions-compact {
    width: 100%;
    justify-content: flex-end;
}

.modal-dialog-sm { max-width: 380px; }

.toast-stack {
    position: fixed;
    bottom: 5.5rem;
    left: 1rem;
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
    max-width: min(320px, calc(100vw - 2rem));
}
.toast {
    padding: .65rem .9rem;
    border-radius: var(--radius);
    font-size: .84rem;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(8px);
    transition: all .25s ease;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast-success { border-color: #bbf7d0; background: var(--success-soft); color: var(--success); }
.toast-error { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }

@media (max-width: 600px) {
    .toast-stack { bottom: 5rem; left: .75rem; }
}

/* ===== Calendar day timeline ===== */
.day-timeline .timeline-event {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--border-light);
}
.day-timeline .timeline-body { flex: 1; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ===== Live clock (topbar) ===== */
.live-clock-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    padding: .2rem .5rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    line-height: 1.25;
    flex-shrink: 0;
    min-width: 0;
}

.live-clock-time {
    font-size: .75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    letter-spacing: .02em;
    color: var(--text);
}

.live-clock-date {
    font-size: .6rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 900px) {
    .live-clock-date {
        display: none;
    }

    .live-clock-bar {
        padding: .18rem .4rem;
    }

    .live-clock-time {
        font-size: .7rem;
    }
}

@media (max-width: 480px) {
    .live-clock-bar {
        padding: .15rem .35rem;
    }

    .live-clock-time {
        font-size: .65rem;
    }
}

.task-countdown {
    display: inline-flex;
    align-items: center;
    padding: .12rem .45rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    white-space: nowrap;
}
.task-countdown.is-soon {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: #fde68a;
}
.task-countdown.is-hours {
    background: var(--info-soft);
    color: var(--info);
    border-color: #bfdbfe;
}
.task-countdown.is-day {
    background: var(--accent-soft);
    color: var(--text-secondary);
}
.task-countdown.is-past {
    background: var(--surface-2);
    color: var(--text-tertiary);
    opacity: .75;
}

.app-layout .page-content {
    padding-bottom: 1rem;
}

/* ===== Dashboard overview ===== */
.dash-page {
    display: flex;
    flex-direction: column;
    gap: .65rem;
    min-height: 0;
    width: 100%;
    margin: 0 auto;
}

.dash-top {
    display: flex;
    align-items: center;
    gap: .75rem 1rem;
    flex-wrap: wrap;
}

.dash-top-main { min-width: 0; flex: 1; }

.dash-top-kicker {
    color: var(--text-tertiary);
    font-size: .72rem;
    margin-bottom: .1rem;
}

.dash-top-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.3;
}

.dash-top-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}

.dash-stat-pill {
    display: inline-flex;
    align-items: baseline;
    gap: .3rem;
    padding: .28rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: .72rem;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.dash-stat-pill strong {
    font-size: .82rem;
    font-weight: 700;
}

.dash-stat-pill span { color: var(--text-tertiary); }

.dash-stat-pill.is-pending {
    border-color: #fde68a;
    background: var(--warning-soft);
}

.dash-stat-pill.is-danger {
    border-color: #fecaca;
    background: var(--danger-soft);
    color: var(--danger);
}

.dash-filters.chip-bar {
    margin: 0;
    padding: 0;
}

.dash-progress-inline {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
}

.dash-progress-inline .progress-track {
    flex: 1;
    height: 5px;
    margin: 0;
}

.dash-progress-label {
    font-size: .68rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.dash-week-compact {
    padding: .65rem .85rem;
    margin: 0;
}

.dash-card-header-compact {
    margin-bottom: .5rem;
}

.dash-card-header-compact h2 {
    font-size: .82rem;
}

.dash-week-compact .dash-week-strip {
    gap: .35rem;
}

.dash-week-compact .dash-week-day {
    padding: .4rem .25rem;
    text-align: center;
    align-items: center;
}

.dash-week-compact .dash-week-name {
    font-size: .64rem;
    line-height: 1.35;
    white-space: nowrap;
}

.dash-week-pending {
    font-size: .58rem;
    color: var(--warning);
    font-weight: 600;
}

.dash-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(180px, 220px);
    gap: .65rem;
    flex: 1;
    min-height: 0;
}

.dash-col {
    padding: .65rem .85rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.dash-col-side {
    gap: 0;
    padding-bottom: .5rem;
}

.dash-schedule-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.dash-schedule-compact .schedule-item,
.dash-schedule-item {
    padding: .45rem .5rem;
    gap: .45rem;
}

.dash-schedule-compact .schedule-time {
    font-size: .72rem;
    min-width: 2.5rem;
}

.dash-schedule-compact .schedule-info a {
    font-size: .8rem;
}

.item-meta-compact {
    gap: .35rem;
    font-size: .68rem;
}

.dash-empty {
    color: var(--text-tertiary);
    font-size: .78rem;
    text-align: center;
    padding: .75rem .5rem;
    margin: 0;
}

.dash-more-link {
    display: block;
    text-align: center;
    font-size: .72rem;
    color: var(--info);
    padding: .4rem;
    text-decoration: none;
}

.dash-side-block {
    padding-bottom: .55rem;
    margin-bottom: .55rem;
    border-bottom: 1px solid var(--border-light);
}

.dash-side-block-last {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dash-side-list {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.dash-side-item {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: .35rem .45rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: inherit;
    text-decoration: none;
    font-size: .78rem;
}

.dash-side-item small {
    font-size: .65rem;
    color: var(--text-tertiary);
}

.dash-side-item-danger {
    border-right: 2px solid var(--danger);
}

.dash-activity-compact {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.dash-activity-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .35rem .5rem;
    padding: .3rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: .72rem;
    align-items: baseline;
}

.dash-activity-row:last-child { border-bottom: none; }

.dash-activity-who {
    font-weight: 600;
    white-space: nowrap;
}

.dash-activity-what {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-activity-when {
    color: var(--text-tertiary);
    white-space: nowrap;
    font-size: .65rem;
}

@media (min-width: 901px) {
    .dash-columns {
        flex: 1;
        min-height: 0;
    }
}

.dash-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.dash-hero-kicker {
    color: var(--text-tertiary);
    font-size: .8rem;
    margin-bottom: .25rem;
}
.dash-hero h1 {
    font-size: clamp(1.2rem, 3vw, 1.75rem);
    letter-spacing: -.02em;
}
.dash-hero-sub {
    margin-top: .35rem;
    color: var(--text-secondary);
    font-size: .84rem;
}
.dash-progress { margin-bottom: 1rem; }
.dash-section-sub {
    margin-top: .2rem;
    color: var(--text-tertiary);
    font-size: .75rem;
}
.dash-week-card { margin-bottom: 1rem; }
.dash-week-strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .45rem;
}
.dash-week-day {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 0;
    padding: .55rem .45rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: inherit;
    transition: all var(--transition);
}
.dash-week-day:hover {
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow-xs);
    text-decoration: none;
}
.dash-week-day.is-today {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: var(--shadow-xs);
}
.dash-week-day.is-tomorrow {
    border-color: var(--info);
}
.dash-week-name {
    font-size: .72rem;
    font-weight: 600;
}
.dash-week-date {
    font-size: .68rem;
    color: var(--text-tertiary);
    direction: ltr;
}
.dash-week-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 .35rem;
    border-radius: 999px;
    background: var(--surface);
    font-size: .68rem;
    font-weight: 700;
    align-self: flex-start;
}
.dash-week-events {
    list-style: none;
    margin-top: .15rem;
}
.dash-week-events li {
    font-size: .62rem;
    color: var(--text-secondary);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-week-empty { color: var(--text-tertiary); }
.dash-focus-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.dash-secondary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.dash-header-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.dash-mini-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
}
.dash-mini-stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: inherit;
    text-decoration: none;
}
.dash-mini-stat strong {
    font-size: 1.25rem;
    line-height: 1;
}
.dash-mini-stat span {
    font-size: .72rem;
    color: var(--text-tertiary);
}
.sm-week-card .dash-week-events { display: none; }

@media (max-width: 900px) {
    .dash-columns {
        grid-template-columns: 1fr;
    }
    .dash-page {
        height: auto;
        max-height: none;
    }
    .dash-schedule-list {
        max-height: 280px;
    }
    .dash-focus-grid { grid-template-columns: 1fr; }
    .dash-week-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .app-layout .page-content {
        padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + .75rem);
    }
}
@media (max-width: 600px) {
    .dash-hero { flex-direction: column; }
    .dash-week-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== Insight Hub ===== */
.insight-hub {
    margin-bottom: 1rem;
}
.insight-hub-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.focus-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: linear-gradient(145deg, var(--surface) 0%, var(--surface-2) 100%);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
}
.focus-card.is-pinned {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent);
}
.focus-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem;
}
.focus-card-kicker {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.focus-card-body {
    display: block;
    color: inherit;
    text-decoration: none;
}
.focus-card-body h2 {
    font-size: 1.15rem;
    margin: 0 0 .35rem;
    line-height: 1.35;
}
.focus-card-foot {
    margin-top: .75rem;
    padding-top: .65rem;
    border-top: 1px dashed var(--border-light);
}
.insight-stack {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    padding: .9rem 1rem;
}
.insight-velocity-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
    color: var(--text-secondary);
}
.insight-velocity-head strong {
    font-size: 1.1rem;
    color: var(--primary);
}
.insight-velocity-bar { margin: .4rem 0; }
.insight-velocity small { color: var(--text-tertiary); font-size: .72rem; }
.team-pulse {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .55rem .65rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.team-pulse-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-tertiary);
}
.team-pulse-row {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
}
.team-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
}
.team-pulse-dot.is-online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.team-pulse-chip {
    font-size: .68rem;
    padding: .2rem .5rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    color: inherit;
    text-decoration: none;
}
.team-pulse-chip.is-alert {
    background: var(--danger-soft);
    border-color: transparent;
    color: var(--danger);
}
.insight-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}
.insight-item {
    display: flex;
    align-items: flex-start;
    gap: .45rem;
    font-size: .78rem;
    line-height: 1.45;
    padding: .45rem .55rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.insight-item a { color: inherit; text-decoration: none; }
.insight-item a:hover { color: var(--primary); }
.insight-danger { border-right: 3px solid var(--danger); }
.insight-warning { border-right: 3px solid #f59e0b; }
.insight-success { border-right: 3px solid #22c55e; }
.insight-info { border-right: 3px solid var(--primary); }
.insight-purple { border-right: 3px solid #9333ea; }
.day-timeline {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    padding: .85rem 1rem;
}
.day-timeline-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .65rem;
}
.day-timeline-head h3 {
    margin: 0;
    font-size: .85rem;
}
.day-timeline-track {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: .35rem;
    max-height: 140px;
    overflow-y: auto;
}
.day-timeline-slot {
    min-height: 52px;
    padding: .35rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid transparent;
}
.day-timeline-slot.has-events {
    border-color: color-mix(in srgb, var(--primary) 20%, transparent);
    background: color-mix(in srgb, var(--primary) 6%, var(--surface-2));
}
.day-timeline-hour {
    display: block;
    font-size: .62rem;
    color: var(--text-tertiary);
    direction: ltr;
    text-align: left;
}
.day-timeline-event {
    display: block;
    margin-top: .2rem;
    font-size: .62rem;
    padding: .15rem .3rem;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Command Palette ===== */
.cmd-palette {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 1rem 1rem;
}
.cmd-palette[hidden] { display: none !important; }
.cmd-palette-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
}
.cmd-palette-panel {
    position: relative;
    width: min(520px, 100%);
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.cmd-palette-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border-light);
}
.cmd-palette-search input {
    flex: 1;
    border: none;
    background: transparent;
    font: inherit;
    outline: none;
}
.cmd-palette-icon { opacity: .5; }
.cmd-palette-list {
    max-height: 320px;
    overflow-y: auto;
    padding: .35rem;
}
.cmd-palette-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font: inherit;
    text-align: right;
    cursor: pointer;
    color: inherit;
}
.cmd-palette-item.is-active,
.cmd-palette-item:hover {
    background: var(--surface-2);
}
.cmd-palette-label { flex: 1; font-weight: 600; }
.cmd-palette-hint { font-size: .72rem; color: var(--text-tertiary); }
.cmd-palette-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: .85rem;
}
.cmd-palette-foot {
    display: flex;
    gap: 1rem;
    padding: .55rem 1rem;
    border-top: 1px solid var(--border-light);
    font-size: .68rem;
    color: var(--text-tertiary);
}
.cmd-palette-foot kbd,
.cmd-palette-search kbd {
    font-size: .62rem;
    padding: .1rem .35rem;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    background: var(--surface-2);
}

@media (max-width: 900px) {
    .insight-hub-grid { grid-template-columns: 1fr; }
    .day-timeline-track { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
