:root {
    color-scheme: light;
    --bg: #f6f5f1;
    --surface: #ffffff;
    --surface-soft: #f1f3f4;
    --ink: #252525;
    --muted: #697071;
    --line: #dedbd4;
    --accent: #286a5b;
    --accent-strong: #1f5147;
    --accent-soft: #dfeee9;
    --warn: #b45f25;
    --danger: #9f3434;
    --shadow: 0 18px 50px rgba(20, 26, 24, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-panel h1,
.top-strip h1,
.panel h2,
.section-toolbar h2,
.ai-header h2,
.modal-header h2 {
    margin: 0;
    letter-spacing: 0;
}

.login-panel form,
.modal-fields {
    display: grid;
    gap: 12px;
}

label {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-panel button,
.primary-btn,
.chat-composer button {
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    font-weight: 800;
}

.login-panel button:hover,
.primary-btn:hover,
.chat-composer button:hover {
    background: var(--accent-strong);
}

.ghost-btn,
.context-actions button,
.bottom-nav button,
.icon-btn {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    padding: 9px 12px;
    font-weight: 700;
}

.ghost-btn:hover,
.context-actions button:hover,
.bottom-nav button:hover {
    background: var(--surface-soft);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(360px, 2fr);
}

.workspace {
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
}

.top-strip {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 26px 28px 18px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.86rem;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.daily-phrase {
    margin: 8px 0 0;
    color: var(--muted);
}

.view {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 28px 86px;
}

.view.active {
    display: block;
}

.home-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 16px;
}

.hero-panel {
    grid-row: span 2;
}

.panel,
.kanban-column,
.item-row,
.notion-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel {
    padding: 18px;
}

.panel-heading,
.section-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.section-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg);
    padding: 12px 0 14px;
}

.task-preview-list,
.compact-list,
.table-list,
.cards-grid {
    display: grid;
    gap: 10px;
}

.task-preview,
.compact-item,
.item-row,
.notion-card {
    padding: 13px;
}

.task-preview {
    display: grid;
    gap: 8px;
    border-bottom: 1px solid var(--line);
}

.task-preview:last-child {
    border-bottom: 0;
}

.meta,
.empty-state,
.cost-line {
    color: var(--muted);
    font-size: 0.83rem;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    padding: 3px 8px;
    font-size: 0.76rem;
    font-weight: 800;
}

.pill.priority-alta {
    color: #8c321f;
    background: #f7ddd4;
}

.pill.priority-media {
    color: #8a5a0b;
    background: #f4e7c7;
}

.pill.done {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.kanban {
    display: grid;
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 12px;
}

.kanban-column {
    min-height: 420px;
    padding: 12px;
}

.kanban-column h3 {
    margin: 0 0 10px;
    font-size: 0.95rem;
}

.kanban-card {
    display: grid;
    gap: 8px;
    width: 100%;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 12px;
    text-align: left;
}

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

.day-cell {
    min-height: 130px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.day-number {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
}

.calendar-chip {
    margin-top: 8px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    padding: 6px;
    font-size: 0.78rem;
    font-weight: 800;
}

.item-row {
    display: grid;
    grid-template-columns: 130px 1fr auto;
    align-items: center;
    gap: 12px;
}

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

.notion-card {
    display: grid;
    gap: 10px;
    min-height: 160px;
    text-align: left;
}

.notion-card h3,
.compact-item h3,
.item-row h3 {
    margin: 0;
    font-size: 1rem;
}

.bottom-nav {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding: 12px 28px;
    background: rgba(246, 245, 241, 0.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
}

.bottom-nav button.active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.ai-panel {
    height: 100vh;
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    background: #fbfaf7;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 22px 14px;
    border-bottom: 1px solid var(--line);
}

.ai-controls {
    display: grid;
    gap: 10px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
}

.context-actions,
.context-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.context-actions button,
.context-chip {
    padding: 7px 9px;
    font-size: 0.78rem;
}

.context-chip {
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 800;
}

.briefing-btn {
    border: 1px solid #c7b47a;
    border-radius: 7px;
    background: #fff6d9;
    color: #6f5211;
    padding: 9px 12px;
    font-weight: 900;
}

.chat-thread {
    overflow: auto;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 94%;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 12px;
    white-space: pre-wrap;
}

.message.user {
    align-self: flex-end;
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.message.assistant {
    align-self: flex-start;
}

.message.system {
    max-width: 100%;
    background: var(--surface-soft);
    color: var(--muted);
}

.suggested-actions {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.suggested-action {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px;
    background: #fff;
}

.chat-composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--line);
}

.modal {
    width: min(720px, calc(100vw - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow);
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.28);
}

.modal-card {
    padding: 18px;
}

.modal-header,
.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.modal-header {
    margin-bottom: 16px;
}

.modal-actions {
    margin-top: 18px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 1.3rem;
}

#delete-entity-btn {
    color: var(--danger);
}

.form-message {
    min-height: 22px;
    margin: 0;
    color: var(--danger);
    font-weight: 800;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .workspace,
    .ai-panel {
        height: auto;
        min-height: 100vh;
    }

    .ai-panel {
        border-top: 1px solid var(--line);
    }

    .home-grid,
    .kanban,
    .calendar-board {
        grid-template-columns: 1fr;
    }

    .bottom-nav {
        grid-template-columns: repeat(3, 1fr);
    }

    .item-row {
        grid-template-columns: 1fr;
    }
}
