:root {
    --bg: #f5f4f1;
    --surface: #ffffff;
    --surface-soft: #faf9f7;
    --line: #e7e4de;
    --text: #171717;
    --muted: #6d685f;
    --accent: #111827;
    --accent-soft: #f1f5f9;
    --danger: #dc2626;
    --success: #0f766e;
    --radius: 20px;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

body[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #111827;
    --surface-soft: #1f2937;
    --line: #334155;
    --text: #e5eefc;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-soft: #172554;
    --danger: #f87171;
    --success: #2dd4bf;
    --shadow: 0 16px 40px rgba(2, 6, 23, 0.4);
}

body[data-theme="brand"] {
    --bg: #eef2ff;
    --surface: #ffffff;
    --surface-soft: #edf3ff;
    --line: #c7d2fe;
    --text: #17154c;
    --muted: #5a5f8f;
    --accent: #1a237e;
    --accent-soft: #dbeafe;
    --danger: #be185d;
    --success: #2563eb;
    --shadow: 0 14px 34px rgba(44, 58, 140, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", sans-serif;
}

.ambient {
    display: none;
}

.shell,
.login-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 22px auto 34px;
}

.topbar,
.panel,
.summary-card,
.login-card,
.tabs-shell {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo {
    width: clamp(108px, 16vw, 164px);
    height: auto;
    flex: 0 0 auto;
    display: block;
}

.identity-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

.subtitle,
.muted,
.hint,
.detail-body {
    color: var(--muted);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: 1.35rem;
}

h2 {
    margin-bottom: 0;
    font-size: 1.05rem;
}

.nav,
.tabs-nav,
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav a,
.button,
.tab-link,
.danger-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.nav a,
.button {
    background: var(--accent);
    color: #fff;
}

.button.secondary,
.tab-link {
    background: var(--accent-soft);
    color: var(--text);
}

.tab-link.active {
    background: var(--accent);
    color: #fff;
}

.danger-button {
    background: #fee2e2;
    color: var(--danger);
}

.danger-button.small {
    padding: 8px 12px;
}

.icon-button {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--accent-soft);
    color: var(--text);
    font-size: 1.4rem;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: var(--success);
    font-weight: 700;
}

.summary-strip {
    margin-bottom: 16px;
}

.summary-card {
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
    padding: 18px;
    border-radius: var(--radius);
}

.summary-card span {
    color: var(--muted);
}

.summary-card strong {
    font-size: 1.8rem;
}

.panel {
    padding: 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.panel.compact {
    padding: 16px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.month-form,
.entry-form {
    display: grid;
    gap: 12px;
}

.entry-top-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.entry-top-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

.segments-box {
    padding: 14px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.segments-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.segments-list {
    display: grid;
    gap: 10px;
}

.segment-row {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 0.8fr)) auto;
    gap: 10px;
}

.segment-project-picker {
    display: grid;
    gap: 8px;
    position: relative;
}

.project-native-select {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    padding: 0;
    border: 0;
}

.project-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 4px;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.project-result-option {
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    text-align: left;
    background: var(--surface-soft);
    color: var(--text);
    cursor: pointer;
    font: inherit;
}

.project-result-option:hover {
    background: var(--accent-soft);
}

.segment-remove {
    border: 0;
    border-radius: 12px;
    background: #fee2e2;
    color: var(--danger);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.entry-object {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 8px 8px 0;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--accent-soft);
}

.entry-object span {
    color: var(--muted);
    font-size: 0.9rem;
}

.meta-note {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.85rem;
}

details {
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    margin-bottom: 8px;
}

summary {
    cursor: pointer;
    font-weight: 700;
}

.tabs-shell {
    padding: 10px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.login-shell {
    min-height: calc(100vh - 44px);
    display: grid;
    grid-template-columns: minmax(320px, 420px);
    justify-content: center;
    align-items: center;
}

.login-card {
    padding: 32px 28px;
    border-radius: 24px;
    display: grid;
    gap: 14px;
}

.login-logo {
    width: min(240px, 100%);
    height: auto;
    display: block;
    margin: 0 auto 6px;
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 1.4rem;
    text-align: center;
}

.error {
    margin: 0;
    color: var(--danger);
    font-weight: 700;
}

.empty {
    color: var(--muted);
}

@media (max-width: 1024px) {
    .login-shell {
        grid-template-columns: minmax(280px, 420px);
    }
}

@media (max-width: 820px) {
    .shell,
    .login-shell {
        width: calc(100% - 20px);
        margin-top: 10px;
    }

    .topbar,
    .panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .entry-top-grid,
    .entry-top-grid.two,
    .segment-row {
        grid-template-columns: 1fr;
    }

    .theme-grid {
        grid-template-columns: 1fr;
    }

    .brand-lockup {
        flex-wrap: wrap;
        justify-content: center;
    }

    .brand-logo {
        width: min(180px, 62vw);
        margin-inline: auto;
    }
}

.inline-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.feature-box {
    padding: 14px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    display: grid;
    gap: 10px;
}

.field-label {
    font-weight: 700;
}

.settings-grid,
.draft-grid {
    display: grid;
    gap: 16px;
}

.settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.draft-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.draft-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
}

.settings-theme-form {
    display: grid;
    gap: 18px;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.theme-card {
    position: relative;
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-soft);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

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

.theme-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-card.active,
.theme-card:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08);
}

body[data-theme="dark"] .theme-card.active,
body[data-theme="dark"] .theme-card:has(input:checked),
body[data-theme="brand"] .theme-card.active,
body[data-theme="brand"] .theme-card:has(input:checked) {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.theme-card-title {
    font-weight: 700;
}

.theme-preview {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 8px;
    min-height: 86px;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: #f8fafc;
}

.theme-preview-bar,
.theme-preview-surface,
.theme-preview-accent {
    display: block;
    border-radius: 12px;
}

.theme-preview-bar {
    grid-column: 1 / -1;
    min-height: 18px;
}

.theme-preview-surface,
.theme-preview-accent {
    min-height: 40px;
}

.theme-card[data-theme-preview="standard"] .theme-preview {
    background: #f5f4f1;
}

.theme-card[data-theme-preview="standard"] .theme-preview-bar {
    background: #111827;
}

.theme-card[data-theme-preview="standard"] .theme-preview-surface {
    background: #ffffff;
}

.theme-card[data-theme-preview="standard"] .theme-preview-accent {
    background: #f1f5f9;
}

.theme-card[data-theme-preview="dark"] .theme-preview {
    background: #0f172a;
}

.theme-card[data-theme-preview="dark"] .theme-preview-bar {
    background: #38bdf8;
}

.theme-card[data-theme-preview="dark"] .theme-preview-surface {
    background: #111827;
}

.theme-card[data-theme-preview="dark"] .theme-preview-accent {
    background: #1f2937;
}

.theme-card[data-theme-preview="brand"] .theme-preview {
    background: linear-gradient(135deg, #eef2ff 0%, #dbeafe 100%);
}

.theme-card[data-theme-preview="brand"] .theme-preview-bar {
    background: linear-gradient(90deg, #171d95 0%, #d94a7f 100%);
}

.theme-card[data-theme-preview="brand"] .theme-preview-surface {
    background: #ffffff;
}

.theme-card[data-theme-preview="brand"] .theme-preview-accent {
    background: linear-gradient(180deg, #93c5fd 0%, #c4b5fd 100%);
}

.calendar-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.calendar-head {
    padding: 8px;
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.calendar-cell {
    min-height: 78px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.calendar-cell,
.calendar-head {
    min-width: 0;
}

.calendar-cell strong {
    font-size: 1rem;
    line-height: 1;
}

.calendar-cell span,
.calendar-cell em {
    font-size: 0.78rem;
    color: var(--muted);
    font-style: normal;
    line-height: 1.2;
    word-break: break-word;
}

.calendar-cell.has-entry {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.calendar-cell.has-draft {
    border-color: #fde68a;
}

.calendar-cell.today {
    outline: 2px solid #93c5fd;
}

.calendar-cell.empty {
    background: transparent;
    border-style: dashed;
    cursor: default;
}

.checkbox-grid,
.object-summary-grid {
    display: grid;
    gap: 12px;
}

.checkbox-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.checkbox-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
}

.checkbox-chip input {
    width: auto;
    margin: 0;
}

.object-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 16px;
}

.report-meta {
    display: grid;
    gap: 8px;
}

.detail-stack {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.detail-card {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    display: grid;
    gap: 4px;
}

@media (max-width: 820px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .calendar-scroll {
        margin-inline: -4px;
        padding-inline: 4px;
    }

    .calendar-grid {
        min-width: 640px;
        gap: 6px;
    }

    .calendar-head {
        position: sticky;
        top: 0;
        z-index: 1;
        padding: 6px 4px;
        font-size: 0.74rem;
        background: var(--surface);
        border-radius: 10px;
    }

    .calendar-cell {
        min-height: 70px;
        padding: 8px;
        border-radius: 12px;
    }

    .calendar-cell strong {
        font-size: 0.95rem;
    }

    .calendar-cell span,
    .calendar-cell em {
        font-size: 0.72rem;
    }
}
.assistant-answer {
    white-space: normal;
    line-height: 1.6;
}
