:root {
    --brand:        #1B4FB8;
    --brand-dark:   #133A8A;
    --brand-light:  #E8EFFA;
    --bg:           #F5F7FB;
    --surface:      #FFFFFF;
    --border:       #E1E5EE;
    --text:         #1A2032;
    --text-muted:   #6B7180;
    --status-not:   #9AA1B3;
    --status-prog:  #E5A100;
    --status-block: #D93636;
    --status-done:  #2E9F5C;
    --priority-critical: #FF5722;
    --priority-high:     #FFA000;
    --shadow: 0 1px 3px rgba(20,30,60,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif; color: var(--text); background: var(--bg); }
button, select, input, textarea { font: inherit; color: inherit; }

.hidden { display: none !important; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1.5rem; background: var(--brand); color: white;
    box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.01em; }
.brand-mark { font-size: 1.35rem; }
.counters { display: flex; gap: 1.25rem; }
.counter { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.counter-num { font-size: 1.5rem; font-weight: 700; }
.counter-lbl { font-size: 0.7rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.05em; }

.status-tabs {
    display: flex; gap: 0; padding: 0 1.5rem; background: var(--surface);
    border-bottom: 1px solid var(--border); overflow-x: auto;
}
.status-tab {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.85rem 1.1rem; background: transparent; border: none; cursor: pointer;
    font-size: 0.92rem; font-weight: 500; color: var(--text-muted);
    border-bottom: 3px solid transparent; white-space: nowrap;
    transition: color 0.12s, border-color 0.12s;
}
.status-tab:hover { color: var(--text); }
.status-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.status-tab .tab-count {
    background: var(--bg); color: var(--text-muted); padding: 0.1rem 0.5rem;
    border-radius: 999px; font-size: 0.75rem; font-weight: 700;
}
.status-tab.active .tab-count { background: var(--brand-light); color: var(--brand-dark); }
.status-tab[data-tab="Not Started"].active { color: var(--status-not); border-bottom-color: var(--status-not); }
.status-tab[data-tab="In Progress"].active { color: var(--status-prog); border-bottom-color: var(--status-prog); }
.status-tab[data-tab="Blocked"].active     { color: var(--status-block); border-bottom-color: var(--status-block); }
.status-tab[data-tab="Done"].active        { color: var(--status-done); border-bottom-color: var(--status-done); }

.per-owner {
    display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.owner-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.3rem 0.7rem; border-radius: 999px;
    background: var(--brand-light); color: var(--brand-dark);
    border: 1px solid transparent; cursor: pointer; font-size: 0.85rem; font-weight: 500;
    transition: all 0.12s ease;
}
.owner-chip:hover { background: var(--brand); color: white; }
.owner-chip.active { background: var(--brand); color: white; border-color: var(--brand-dark); }
.owner-chip .owner-count { background: rgba(255,255,255,0.4); padding: 0.05rem 0.4rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.owner-chip.active .owner-count { background: rgba(255,255,255,0.25); }

.controls {
    padding: 0.75rem 1.5rem; background: var(--surface);
    border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.6rem;
}
.filter-group, .toggle-group, .actions {
    display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
}
.filter-group select, .filter-group input[type="search"] {
    padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 6px;
    background: white; min-width: 140px;
}
.filter-group input[type="search"] { min-width: 220px; flex: 1; }
.toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; cursor: pointer; }
.btn-clear, .btn-primary, .btn-secondary, .btn-danger {
    padding: 0.4rem 0.9rem; border-radius: 6px; border: 1px solid transparent;
    cursor: pointer; font-weight: 500; font-size: 0.9rem;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: white; color: var(--brand); border-color: var(--brand); }
.btn-secondary:hover { background: var(--brand-light); }
.btn-danger { background: white; color: var(--status-block); border-color: var(--status-block); }
.btn-danger:hover { background: var(--status-block); color: white; }
.btn-clear { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-clear:hover { background: var(--bg); }

.items-wrap { padding: 1rem 1.5rem; }
#items { display: flex; flex-direction: column; gap: 0.5rem; }

.item {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.65rem 0.85rem; display: grid;
    grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: start;
    transition: box-shadow 0.12s, transform 0.12s, opacity 0.4s;
    cursor: pointer;
}
.item:hover { box-shadow: var(--shadow); border-color: var(--brand-light); }
.item.flash-out { opacity: 0; transform: translateX(8px); pointer-events: none; }
.item.flash-in  { animation: flashIn 0.5s ease; }
@keyframes flashIn {
    from { background: var(--brand-light); }
    to   { background: var(--surface); }
}
.item.archived { opacity: 0.55; }
.item.done { opacity: 0.7; }

.item .status-pill {
    padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
    color: white; cursor: pointer; white-space: nowrap; min-width: 100px; text-align: center;
    border: none; user-select: none;
}
.status-pill.not-started { background: var(--status-not); }
.status-pill.in-progress { background: var(--status-prog); }
.status-pill.blocked     { background: var(--status-block); }
.status-pill.done        { background: var(--status-done); }

.item-body { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.item-text { font-size: 0.95rem; line-height: 1.35; word-break: break-word; }
.item.done .item-text { text-decoration: line-through; color: var(--text-muted); }
.item-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; font-size: 0.72rem; }
.tag { padding: 0.15rem 0.5rem; border-radius: 4px; background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.tag.owner { background: var(--brand-light); color: var(--brand-dark); border-color: transparent; font-weight: 600; }
.tag.priority-critical { background: var(--priority-critical); color: white; border-color: transparent; font-weight: 700; }
.tag.priority-high { background: var(--priority-high); color: white; border-color: transparent; font-weight: 600; }
.tag.client { background: #FFF3E0; color: #BF6300; border-color: #FFDAA8; }
.tag.deadline { background: white; color: var(--text-muted); }
.tag.deadline.overdue { background: var(--status-block); color: white; border-color: transparent; font-weight: 600; }
.tag.deadline.today { background: var(--status-prog); color: white; border-color: transparent; font-weight: 600; }
.tag.source { background: transparent; color: var(--text-muted); border: none; padding-left: 0; font-style: italic; }
.item-notes { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }

.item-actions { display: flex; gap: 0.25rem; align-items: center; }
.icon-btn {
    background: transparent; border: none; cursor: pointer; padding: 0.3rem;
    border-radius: 4px; color: var(--text-muted); font-size: 0.95rem;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }

.modal {
    position: fixed; inset: 0; background: rgba(20,30,60,0.4);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    padding: 1rem;
}
.modal-box {
    background: white; border-radius: 10px; padding: 1.5rem; width: 100%; max-width: 540px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto;
}
.modal-box.wide { max-width: 820px; }
.modal-box h2 { margin: 0 0 0.5rem; color: var(--brand); }
.modal-box h3 { margin: 1rem 0 0.5rem; }
.modal-box form label { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.6rem 0; font-size: 0.85rem; color: var(--text-muted); }
.modal-box form label input, .modal-box form label select, .modal-box form label textarea {
    padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; color: var(--text);
}
.modal-box .row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
#paste-text { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem; font-family: inherit; font-size: 0.9rem; }
.hint { font-size: 0.85rem; color: var(--text-muted); margin: 0.4rem 0; }

.extract-item {
    border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0.4rem 0;
    display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start;
}
.extract-item input[type="checkbox"] { margin-top: 0.25rem; }
.extract-item .extract-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }

.side-panel {
    position: fixed; top: 0; right: 0; width: 440px; max-width: 100vw; height: 100vh;
    background: white; box-shadow: -8px 0 30px rgba(0,0,0,0.18);
    z-index: 80; display: flex; flex-direction: column;
    transform: translateX(0); transition: transform 0.22s ease-out;
}
.side-panel.hidden { transform: translateX(100%); pointer-events: none; display: flex; }
.side-panel-inner { display: flex; flex-direction: column; height: 100%; }
.side-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--brand-light);
}
.side-panel-head h2 { margin: 0; color: var(--brand-dark); font-size: 1.1rem; }
.side-panel-body { padding: 1rem 1.25rem; overflow-y: auto; flex: 1; }

.field-block { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.7rem 0; }
.field-lbl { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field-block textarea, .field-block input, .field-block select {
    padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.95rem; color: var(--text); background: white;
}
.field-block textarea { resize: vertical; font-family: inherit; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.status-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.status-btn {
    flex: 1; min-width: 90px; padding: 0.55rem 0.6rem; border-radius: 6px;
    border: 2px solid transparent; background: var(--bg); color: var(--text-muted);
    cursor: pointer; font-weight: 600; font-size: 0.85rem;
    transition: all 0.12s;
}
.status-btn:hover { background: var(--brand-light); }
.status-btn.active.st-not-started { background: var(--status-not);   color: white; border-color: var(--status-not); }
.status-btn.active.st-in-progress { background: var(--status-prog);  color: white; border-color: var(--status-prog); }
.status-btn.active.st-blocked     { background: var(--status-block); color: white; border-color: var(--status-block); }
.status-btn.active.st-done        { background: var(--status-done);  color: white; border-color: var(--status-done); }

.save-row { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0 0.5rem; }
.side-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }

.journey h3 { margin: 0 0 0.6rem; font-size: 0.95rem; color: var(--text); }
.journey-list { display: flex; flex-direction: column; gap: 0.4rem; }
.journey-row {
    display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: center;
    padding: 0.4rem 0.6rem; background: var(--bg); border-radius: 6px; font-size: 0.82rem;
}
.journey-row .from { color: var(--text-muted); text-decoration: line-through; }
.journey-row .arrow { color: var(--text-muted); }
.journey-row .to { font-weight: 600; color: var(--text); }
.journey-row .when { color: var(--text-muted); font-size: 0.75rem; }
.journey-empty { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

@media (max-width: 720px) {
    .topbar { flex-direction: column; gap: 0.5rem; padding: 0.65rem 1rem; }
    .counters { gap: 0.85rem; }
    .modal-box .row { grid-template-columns: 1fr; }
    .item { grid-template-columns: 1fr; }
    .side-panel { width: 100vw; }
    .row-2 { grid-template-columns: 1fr; }
    .status-buttons { flex-direction: column; }
}
