:root {
    --bg: #f7fbff;
    --surface: #ffffff;
    --surface-soft: #f2f8ff;
    --surface-muted: #eef4fb;
    --border: #d7e5f5;
    --text: #13263f;
    --muted: #657a92;
    --primary: #2d8cff;
    --primary-dark: #1767c7;
    --success: #178b5d;
    --error: #c53a3a;
    --warning: #b7791f;
    --shadow: 0 18px 40px rgba(19, 38, 63, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #fbfdff 0%, #f3f8ff 100%);
    color: var(--text);
    line-height: 1.55;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code { background: #eef5ff; padding: 0.15rem 0.35rem; border-radius: 8px; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.narrow-container { width: min(760px, calc(100% - 32px)); margin: 0 auto; }
.page { min-height: calc(100vh - 144px); padding: 24px 0 56px; }
.section { padding: 24px 0; }
.section-narrow { padding-top: 44px; }
.section-gap-top { margin-top: 20px; }
.hero { padding: 54px 0 24px; }
.hero-grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr); align-items: center; }
.hero h1, .dashboard-header h1, .auth-card h1, .install-card h1, .page-header-row h1 { margin: 0 0 12px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.08; }
.lead { color: var(--muted); font-size: 1.03rem; margin: 0; }
.eyebrow { display: inline-block; margin-bottom: 12px; padding: 0.4rem 0.75rem; border-radius: 999px; background: #e8f3ff; color: var(--primary-dark); font-size: 0.86rem; font-weight: 700; }
.muted, .small-text, .meta-line, .sidebar-caption { color: var(--muted); }
.small-text, .meta-line { font-size: 0.92rem; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,0.9); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(215,229,245,0.8); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 76px; }
.brand img { height: 38px; width: auto; }
.topnav { display: flex; align-items: center; gap: 14px; }
.topnav a { font-weight: 600; color: var(--text); }
.nav-toggle { display: none; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 0.55rem 0.75rem; font-size: 1rem; }
.card { background: var(--surface); border: 1px solid rgba(215,229,245,0.95); box-shadow: var(--shadow); border-radius: var(--radius); padding: 24px; }
.card-soft { background: var(--surface-soft); }
.button-row, .hero-actions, .footer-inner, .dashboard-header, .page-header-row, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: linear-gradient(180deg, #45a2ff 0%, #1f84f5 100%); color: #fff; padding: 0.9rem 1.2rem; border-radius: 14px; font-weight: 700; cursor: pointer; box-shadow: 0 10px 24px rgba(45, 140, 255, 0.24); }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-ghost { background: transparent; color: var(--primary-dark); border: 1px solid var(--border); box-shadow: none; }
.button-sm { padding: 0.65rem 0.9rem; border-radius: 12px; }
.inline-form { margin: 0; }
.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.cards-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid { display: grid; gap: 16px; }
.form-two-columns { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-grid { gap: 12px; }
.form-grid label { display: grid; gap: 8px; font-weight: 600; }
.form-grid input, .form-grid textarea, .form-grid select {
    width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: 0.9rem 1rem; font: inherit; color: var(--text); background: #fff;
}
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus { outline: 3px solid rgba(45,140,255,0.14); border-color: #9fcbff; }
.flash { margin-top: 8px; display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; border-radius: 14px; border: 1px solid transparent; }
.flash-success { background: #ecfdf5; color: #11633e; border-color: #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-close { border: 0; background: transparent; cursor: pointer; font-size: 1.2rem; color: inherit; }
.notice { border-radius: 16px; padding: 18px; margin: 18px 0; }
.notice.warning { background: #fff8eb; border: 1px solid #f8deb0; color: #7c5b16; }
.check-list { list-style: none; padding-left: 0; margin: 0; }
.check-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #e4eef9; }
.check-list li:last-child { border-bottom: 0; }
.check-list li.ok span { color: var(--success); font-weight: 700; }
.check-list li.fail span { color: var(--error); font-weight: 700; }
.hero-card, .auth-card, .install-card, .narrow-card { min-height: 100%; }
.hero-metrics { display: grid; gap: 16px; }
.hero-metrics div, .quick-link { padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: #fff; }
.feature-list { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.feature-list li { margin-bottom: 0.5rem; }
.app-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
.sidebar { position: sticky; top: 100px; }
.sidebar-title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.sidebar-meta { margin-top: 8px; margin-bottom: 6px; font-size: 1.15rem; font-weight: 700; }
.sidebar-caption { margin-bottom: 18px; font-size: 0.92rem; }
.sidebar-nav { display: grid; gap: 10px; }
.sidebar-nav a { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 0.9rem; border-radius: 12px; background: #f7fbff; border: 1px solid transparent; color: var(--text); font-weight: 600; }
.sidebar-nav a.active { background: #eaf4ff; border-color: #cae2ff; color: var(--primary-dark); }
.badge-inline { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 0.78rem; }
.dashboard-header { margin-bottom: 20px; align-items: flex-start; }
.dashboard-badge { min-width: 220px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.stat-card span { color: var(--muted); display: block; margin-bottom: 8px; }
.stat-card strong, .dashboard-badge strong { display: block; font-size: 1.35rem; margin-bottom: 6px; }
.page-header-row { margin-bottom: 20px; align-items: flex-start; }
.filter-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; padding: 0.65rem 0.85rem; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 600; }
.chip.is-active { background: #eaf4ff; border-color: #cae2ff; color: var(--primary-dark); }
.stack-list { display: grid; gap: 12px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: #fbfdff; }
.list-item-block { display: block; }
.card-row { align-items: flex-start; }
.align-right { display: grid; gap: 8px; justify-items: end; text-align: right; }
.gap-sm { gap: 10px; }
.quick-links { display: grid; gap: 12px; }
.empty-state { padding: 18px; border: 1px dashed #c5d9f1; border-radius: 16px; background: #fafcff; color: var(--muted); text-align: center; }
.kanban-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.kanban-column { min-height: 320px; }
.kanban-list { display: grid; gap: 12px; }
.kanban-task { border: 1px solid var(--border); border-radius: 16px; background: #fbfdff; padding: 16px; }
.task-card-head, .task-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.status-form select { min-width: 120px; }
.pill { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.pill-low { background: #eef7ff; color: #2e5d85; }
.pill-medium { background: #eaf4ff; color: #165fa6; }
.pill-high { background: #fff5e8; color: #a15b11; }
.pill-urgent { background: #fff0f0; color: #b42323; }
.pill-neutral { background: #eef2f7; color: #4c5f76; }
.color-dot { display: inline-block; width: 18px; height: 18px; border-radius: 999px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(19,38,63,0.08); }
.calendar-grid-header { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.calendar-weekday { text-align: center; font-weight: 700; color: var(--muted); font-size: 0.9rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.calendar-cell { display: block; min-height: 108px; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: #fff; color: var(--text); }
.calendar-cell:hover { text-decoration: none; border-color: #bdd7f6; }
.calendar-cell.is-outside { opacity: 0.55; }
.calendar-cell.is-selected { background: #eef6ff; border-color: #c6def8; }
.calendar-cell.is-today { box-shadow: inset 0 0 0 2px rgba(45,140,255,0.18); }
.calendar-day-num { font-weight: 700; margin-bottom: 8px; }
.calendar-dots { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.calendar-dot { width: 8px; height: 8px; border-radius: 999px; }
.dot-meeting { background: var(--primary); }
.dot-task { background: #f59e0b; }
.is-unread { border-color: #b7d8ff; background: #f5faff; }
.footer { border-top: 1px solid var(--border); background: rgba(255,255,255,0.8); }
.footer-inner { min-height: 68px; color: var(--muted); }
.footer-links { display: flex; gap: 16px; }

@media (max-width: 980px) {
    .hero-grid, .app-grid, .cards-grid, .cards-grid-wide, .stats-grid, .form-two-columns, .kanban-board { grid-template-columns: 1fr; }
    .dashboard-header, .page-header-row, .hero-actions, .footer-inner, .section-head { flex-direction: column; align-items: flex-start; }
    .calendar-grid, .calendar-grid-header { grid-template-columns: repeat(7, minmax(44px, 1fr)); overflow-x: auto; }
}

@media (max-width: 760px) {
    .topbar-inner { min-height: 68px; }
    .nav-toggle { display: inline-flex; }
    .topnav {
        position: absolute; left: 16px; right: 16px; top: 72px; display: none; flex-direction: column; align-items: stretch;
        padding: 16px; background: #fff; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow);
    }
    .topnav.is-open { display: flex; }
    .brand img { height: 34px; }
    .calendar-cell { min-height: 92px; }
}

.stack-lg { display: grid; gap: 24px; }
.stack-md { display: grid; gap: 18px; }
.stack-sm { display: grid; gap: 12px; }
.grid-two { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.page-head, .split-head, .thread-item-row, .inline-create-form { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.split-head.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.chips-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge-pill { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0.4rem 0.8rem; border-radius: 999px; background: #eaf4ff; color: var(--primary-dark); font-weight: 700; }
.button-secondary { background: #f6f9fd; color: var(--primary-dark); border: 1px solid var(--border); box-shadow: none; }
.inline-create-form { flex-wrap: wrap; }
.inline-create-form input[type="text"], .inline-create-form input[type="file"], .inline-create-form select { flex: 1 1 180px; min-width: 0; border: 1px solid var(--border); border-radius: 14px; padding: 0.85rem 0.95rem; font: inherit; background: #fff; }
.thread-list { display: grid; gap: 10px; }
.thread-item { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 16px; background: #fbfdff; color: var(--text); }
.thread-item.active { border-color: #bfd9fb; background: #eef6ff; }
.thread-meta, .thread-snippet { color: var(--muted); font-size: 0.92rem; }
.message-list { display: grid; gap: 12px; max-height: 66vh; overflow: auto; padding-right: 4px; }
.message-item { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 16px; background: #fbfdff; }
.message-item.own { background: #eef6ff; border-color: #c7e0ff; }
.message-head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.9rem; }
.message-head strong { color: var(--text); }
.message-body { white-space: pre-wrap; word-break: break-word; }
.message-file { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.empty-state.small { padding: 14px; font-size: 0.95rem; }
@media (max-width: 980px) { .grid-two { grid-template-columns: 1fr; } }

.locale-switcher { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; }
.locale-switcher a { padding: 0.4rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-size: 0.9rem; }
.locale-switcher a.is-active { background: #eaf4ff; border-color: #c8e0fb; color: var(--primary-dark); }
.section-soft { background: rgba(234, 244, 255, 0.55); }
.section-head-column { flex-direction: column; align-items: flex-start; }
.hero-landing { padding-bottom: 40px; }
@media (max-width: 760px) { .locale-switcher { flex-wrap: wrap; } }
