:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);

    --big-rock: #4f46e5;
    --big-rock-bg: #eef2ff;
    --big-rock-border: #c7d2fe;
    --small-rock: #059669;
    --small-rock-bg: #ecfdf5;
    --small-rock-border: #a7f3d0;
    --sand: #d97706;
    --sand-bg: #fffbeb;
    --sand-border: #fde68a;
    --water: #0284c7;
    --water-bg: #f0f9ff;
    --water-border: #bae6fd;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    min-height: 100vh;
}

/* ── Header ── */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header h1 { font-size: 16px; font-weight: 700; white-space: nowrap; }
.app-header h1 span { color: var(--text-muted); font-weight: 400; }
.nav-link {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}
.nav-link:hover { background: var(--border); color: var(--text); }

/* ── Manage Page ── */
.manage-page {
    max-width: 1000px;
    margin: 32px auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.manage-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.manage-section-header { margin-bottom: 16px; }
.manage-section-toggle { cursor: pointer; user-select: none; }
.manage-section-toggle:hover h2 { color: var(--big-rock); }
.manage-section-header h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.manage-chevron { display: inline-block; width: 14px; font-size: 11px; color: var(--text-muted); }
.manage-section-body { }
.manage-section-body.collapsed { display: none; }
.manage-section-desc { font-size: 12px; color: var(--text-muted); }
.manage-archive-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.manage-archive-bar label { font-size: 13px; color: var(--text-muted); }
.manage-archive-bar input {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}
.manage-result-msg { font-size: 13px; color: var(--text-muted); }
.manage-result-ok { color: var(--small-rock); font-weight: 500; }
.manage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.manage-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    padding: 0 10px 8px 0;
    border-bottom: 1px solid var(--border);
}
.manage-table td {
    padding: 8px 10px 8px 0;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.manage-table tr:last-child td { border-bottom: none; }
.manage-table-cards th:first-child,
.manage-table-cards td:first-child { max-width: 260px; word-break: break-word; }
.manage-row-inactive td { opacity: .45; }
.manage-color-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}
.manage-color-swatch {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #fff;
    font-family: monospace;
}
.manage-color-picker {
    width: 36px; height: 24px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0; cursor: pointer;
    vertical-align: middle;
}
.manage-tag-input {
    width: 52px;
    font-size: 12px;
    font-family: monospace;
    text-align: center;
    text-transform: uppercase;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 4px;
    background: var(--surface);
    color: var(--text);
}
.manage-empty-cell { color: var(--text-muted); font-style: italic; padding: 10px 0; }
.manage-empty-msg { color: var(--text-muted); font-size: 13px; font-style: italic; margin-top: 8px; }
.manage-empty-date { color: var(--text-muted); }
.manage-child-badge {
    font-size: 10px;
    background: var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Toggle Switch */
.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
    width: 32px; height: 18px;
    background: var(--border);
    border-radius: 9px;
    transition: background .2s;
    position: relative;
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 12px; height: 12px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--small-rock); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(14px); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Date Grid (card modal) ── */
.date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.date-field { display: flex; flex-direction: column; gap: 4px; }
.date-field-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.date-field input[type="date"] {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface-2);
    color: var(--text);
}
.date-field input[type="date"]:focus { outline: none; border-color: var(--big-rock); }

/* ── Filter Bar ── */
.filter-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    position: sticky;
    top: 52px;
    z-index: 99;
}
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label { font-size: 12px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.filter-btn {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.filter-btn:hover { border-color: #94a3b8; }
.filter-btn.active {
    color: #fff;
    border-color: transparent;
    background: #475569;  /* fallback for items without a color (e.g. owners) */
}
.filter-sep { width: 1px; height: 20px; background: var(--border); }
.btn-clear-filters {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.btn-clear-filters:hover { color: var(--text); border-color: #94a3b8; }
.filter-bar-actions { margin-left: auto; display: flex; gap: 8px; }
.btn-add-small {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
}
.btn-add-small:hover { background: var(--bg); }

/* ── Board ── */
.board-wrapper { padding: 16px 20px; overflow-x: auto; }

.board {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 900px;
}

.board-header-row {
    display: flex;
    gap: 4px;
}
.board-header-row .bucket-label-col { width: 130px; flex-shrink: 0; }
.col-header {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius);
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.col-header:hover { background: var(--border); }
.col-header.col-header-collapsed {
    flex: 0 0 32px;
    padding: 6px 0;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 10px;
    letter-spacing: .08em;
}
.col-collapsed-label { display: block; }
.col-chevron { font-size: 10px; }

/* ── Swimlane ── */
.swimlane { display: flex; gap: 4px; }

.bucket-label-col {
    width: 130px;
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    padding-top: 2px;
}
.bucket-label {
    writing-mode: horizontal-tb;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 4px 8px;
    border-radius: var(--radius);
    width: 100%;
    text-align: center;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: opacity .15s;
}
.bucket-label:hover { opacity: .8; }
.bucket-label.big-rock  { color: var(--big-rock);  background: var(--big-rock-bg);  border: 1px solid var(--big-rock-border); }
.bucket-label.small-rock { color: var(--small-rock); background: var(--small-rock-bg); border: 1px solid var(--small-rock-border); }
.bucket-label.sand      { color: var(--sand);       background: var(--sand-bg);      border: 1px solid var(--sand-border); }
.swimlane-chevron { font-style: normal; }
.swimlane-count {
    font-size: 10px; font-weight: 700;
    background: rgba(0,0,0,.12); border-radius: 999px;
    padding: 1px 5px; margin-left: 2px;
}
.swimlane-collapsed .bucket-label-col { padding-bottom: 4px; }

/* ── Collapsible filter groups ── */
.filter-label-toggle {
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    padding: 2px 4px;
    margin-right: 2px;
    transition: background .15s;
}
.filter-label-toggle:hover { background: var(--border); }
.filter-active-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: #475569; color: #fff;
    font-size: 10px; font-weight: 700;
    border-radius: 999px; width: 16px; height: 16px;
    margin: 0 2px;
}

/* ── Column Cell ── */
.column-cell {
    flex: 1;
    min-height: 120px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background .15s, border-color .15s;
    position: relative;
}
.column-cell.column-cell-collapsed {
    flex: 0 0 32px;
    min-height: 40px;
    padding: 4px 0;
    align-items: center;
    justify-content: flex-start;
    cursor: default;
}
.col-collapsed-count {
    font-size: 10px; font-weight: 700;
    color: var(--text-muted);
    background: var(--bg);
    border-radius: 999px;
    padding: 1px 5px;
    margin-top: 4px;
}
.column-cell.drag-over {
    background: #f8fafc;
    border-color: #94a3b8;
    border-style: dashed;
}

.column-cell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}
.btn-add-card {
    font-size: 16px;
    line-height: 1;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 4px;
}
.btn-add-card:hover { color: var(--text); background: var(--bg); }

/* WIP Indicator */
.wip-indicator {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: default;
}
.wip-indicator.ok     { background: #f1f5f9; color: var(--text-muted); }
.wip-indicator.warn   { background: #fef9c3; color: #92400e; }
.wip-indicator.over   { background: #fee2e2; color: #991b1b; }
.wip-limit-value { cursor: pointer; text-decoration: underline dotted; }
.wip-limit-input {
    width: 36px; font-size: 11px; font-weight: 700;
    border: 1px solid #94a3b8; border-radius: 4px; padding: 1px 3px;
    text-align: center;
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s, opacity .15s;
    position: relative;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); border-color: #94a3b8; }
.card.dragging { opacity: .4; }
.card.hidden-by-filter { display: none; }

.card-title { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }

.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.tag {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
    opacity: .9;
}

.card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.card-owners { display: flex; gap: 3px; flex-wrap: wrap; }
.owner-avatar {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--surface);
    flex-shrink: 0;
}
.card-timebox { font-size: 10px; color: var(--text-muted); text-align: right; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-children-toggle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
}
.card-children-toggle:hover { color: var(--text); }
.child-cards-list { margin-top: 5px; display: flex; flex-direction: column; gap: 4px; }
.child-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}
.child-card:hover { border-color: #94a3b8; }

/* ── Size Badge ── */
.size-badge {
    font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 1px 5px; border-radius: 4px;
}
.size-badge.big-rock   { background: var(--big-rock-bg);   color: var(--big-rock);  border: 1px solid var(--big-rock-border); }
.size-badge.small-rock { background: var(--small-rock-bg); color: var(--small-rock); border: 1px solid var(--small-rock-border); }
.size-badge.sand       { background: var(--sand-bg);       color: var(--sand);      border: 1px solid var(--sand-border); }

/* ── Water Panel ── */
.water-panel {
    margin: 20px 20px 0;
    background: var(--water-bg);
    border: 1px solid var(--water-border);
    border-radius: var(--radius);
    padding: 16px;
}
.water-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.water-panel-toggle { cursor: pointer; user-select: none; }
.water-panel-title {
    font-size: 13px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--water);
}
.water-panel-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.skills-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.skill-card {
    background: var(--surface);
    border: 1px solid var(--water-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    min-width: 200px;
    max-width: 280px;
    flex: 1;
    position: relative;
}
.skill-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.skill-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.skill-owners { display: flex; flex-wrap: wrap; gap: 4px; }
.owner-chip {
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
    background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; font-weight: 500;
}
.skill-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.skill-card:hover .skill-actions { opacity: 1; }
.btn-icon {
    font-size: 12px; padding: 2px 5px; border-radius: 4px;
    border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.btn-icon:hover { background: var(--bg); }

/* ── Modal ── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.4);
    z-index: 200;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 60px;
    overflow-y: auto;
}
.modal {
    background: var(--surface);
    border-radius: 12px;
    width: 540px;
    max-width: calc(100vw - 40px);
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    position: relative;
    margin-bottom: 40px;
}
.modal h2 { font-size: 16px; margin-bottom: 18px; }
.modal-close {
    position: absolute; top: 16px; right: 16px;
    font-size: 18px; line-height: 1;
    background: none; border: none; cursor: pointer; color: var(--text-muted);
}
.modal-close:hover { color: var(--text); }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
.form-row input[type=text],
.form-row textarea,
.form-row select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
}
.form-row input[type=text]:focus,
.form-row textarea:focus,
.form-row select:focus { outline: none; border-color: #94a3b8; }
.form-row textarea { resize: vertical; min-height: 70px; }

.checkbox-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.checkbox-item {
    display: flex; align-items: center; gap: 5px;
    padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border);
    cursor: pointer; font-size: 12px; user-select: none;
}
.checkbox-item input { cursor: pointer; }
.checkbox-item.checked { border-color: transparent; color: #fff; }

.form-row-2col { display: flex; gap: 12px; }
.form-row-2col .form-row { flex: 1; }

.size-history { display: flex; gap: 10px; align-items: center; }

.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.btn-primary {
    background: #1e293b; color: #fff; border: none;
    padding: 8px 20px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: #0f172a; }
.btn-secondary {
    background: var(--bg); color: var(--text); border: 1px solid var(--border);
    padding: 8px 16px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.btn-secondary:hover { border-color: #94a3b8; }
.btn-danger {
    background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
    padding: 8px 16px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.btn-danger:hover { background: #fecaca; }

.children-section { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.children-section h3 { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.child-list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
    font-size: 12px; margin-bottom: 4px; cursor: pointer;
}
.child-list-item:hover { background: var(--bg); }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: #1e293b; color: #fff;
    padding: 10px 16px; border-radius: 8px;
    font-size: 13px; max-width: 360px;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    animation: slideIn .2s ease;
    line-height: 1.4;
}
.toast.warning { background: #92400e; }
.toast.error   { background: #991b1b; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Utility ── */
.btn-add {
    font-size: 12px; padding: 5px 12px; border-radius: 6px;
    border: 1px dashed var(--border); background: transparent; cursor: pointer; color: var(--text-muted);
}
.btn-add:hover { background: var(--bg); color: var(--text); border-style: solid; }
.hidden { display: none !important; }
