/* ============================================================
   Concept Cube — ArtMoment design system (light, minimal, data-first).
   Tokens & look derived from artmoment-brand-guide.md.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600;700&display=swap');

:root {
    --brand: #253848;
    --brand-light: #34536b;
    --bg: #eef2f5;
    --card: #ffffff;
    --ink: #333333;
    --ink-alt: #1a1a2e;
    --muted: #64748b;
    --line: #e2e8f0;
    --pill: #e9eef3;
    --row-alt: #f7f9fb;
    --hover: #f0f4f7;

    --winner: #27ae60;
    --loser: #e74c3c;
    --untested: #cbd5e1;
    --note: #e0a458;

    --r-sm: 8px; --r-md: 10px; --r-lg: 12px; --r-full: 999px;
    --shadow-card: 0 2px 8px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Source Sans Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

.muted { color: var(--muted); font-weight: 400; }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    padding: 32px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: center;
}
.login-card img.logo { height: 30px; width: auto; margin: 0 auto 4px; }
.login-card h1 { margin: 0; font-size: 20px; color: var(--brand); }
.login-sub { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.login-card input, .login-card button {
    padding: 11px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    font-size: 15px;
    font-family: inherit;
}
.login-card input { background: #fff; color: var(--ink); }
.login-card button { background: var(--brand); color: #fff; border: none; cursor: pointer; font-weight: 700; }
.login-card button:hover { opacity: .9; }
.login-error { color: var(--loser); margin: 0; font-size: 13px; }

/* ---- Topbar (brand header) ---- */
.topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 20px;
    background: var(--brand);
    color: #fff;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .brand-logo { height: 30px; width: auto; filter: brightness(0) invert(1); }
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-title strong { font-size: 16px; font-weight: 700; }
.topbar-title .muted { font-size: 12px; color: rgba(255,255,255,.72); }
.counts { display: flex; gap: 18px; margin-left: 6px; }
.stat { color: rgba(255,255,255,.72); font-size: 12px; }
.stat b { color: #fff; font-size: 16px; font-weight: 700; }
.stat-winner b { color: #4ade80; }
.stat-loser b { color: #f87171; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* segmented view toggle (Kostka / Tabulka) */
.view-toggle { margin-left: auto; display: inline-flex; background: rgba(255,255,255,.12); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.view-toggle .seg { border: none; background: transparent; color: rgba(255,255,255,.8); padding: 6px 14px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.view-toggle .seg.active { background: #fff; color: var(--brand); }

.btn {
    padding: 8px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--brand);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn-primary:hover { opacity: .9; background: var(--brand); }
/* Ghost buttons that sit on the brand header */
.topbar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger { color: var(--loser); }

/* ---- Filters ---- */
.filters {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding: 16px 20px 6px;
}
.filter-group {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    padding: 12px 14px;
}
.filter-group h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: var(--r-full);
    border: 1px solid var(--line);
    background: var(--pill);
    color: var(--ink);
    cursor: pointer;
    font-size: 12px;
    user-select: none;
}
.chip:hover { background: var(--hover); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip.off { opacity: .4; text-decoration: line-through; }

.hint { margin: 8px 20px 10px; font-size: 12px; }

/* ---- 3D Cube view ---- */
.cube-stage {
    position: relative;
    margin: 0 20px 24px;
    height: calc(100vh - 250px);
    min-height: 460px;
    border-radius: var(--r-lg);
    background: radial-gradient(ellipse at 50% 42%, #2f4b63 0%, #253848 55%, #1a2a37 100%);
    border: 1px solid var(--line);
    overflow: hidden;
    perspective: 1100px;
    cursor: grab;
    user-select: none;
}
.cube-stage.dragging { cursor: grabbing; }
.cube-scene { position: absolute; inset: 0; transform-style: preserve-3d; }
.pt {
    position: absolute;
    left: 50%; top: 50%;
    width: 13px; height: 13px;
    border-radius: 3px;
    cursor: pointer;
    transition: box-shadow .15s;
}
.pt.winner { box-shadow: 0 0 0 2px #4ade80, 0 0 10px rgba(74,222,128,.5); }
.pt.loser { box-shadow: 0 0 0 2px #f87171; opacity: .32; }
.pt.has-note { outline: 2px dotted var(--note); outline-offset: 2px; }
.cube-hint {
    position: absolute; top: 14px; right: 18px;
    font-size: 11px; color: rgba(255,255,255,.5); text-align: right; line-height: 1.5;
    pointer-events: none;
}
.cube-info {
    position: absolute; bottom: 16px; left: 16px;
    background: rgba(13,18,32,.9); border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--r-sm); padding: 12px 16px; font-size: 13px; max-width: 340px;
    color: #e8e6de; pointer-events: none;
}
.cube-info .p { color: #f5b800; font-weight: 700; margin-bottom: 3px; }
.cube-info .a { color: #fff; }
.cube-info .f { color: rgba(255,255,255,.6); }
.cube-info .s { margin-top: 5px; font-size: 12px; }
.cube-info .s.winner { color: #4ade80; }
.cube-info .s.loser { color: #f87171; }

/* ---- Grid ---- */
.grid-wrap { margin: 0 20px 40px; max-height: calc(100vh - 250px); overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); }
table.cube { border-collapse: collapse; background: var(--card); }
table.cube th, table.cube td { border: 1px solid var(--line); }
table.cube thead th {
    position: sticky;
    top: 0;
    background: var(--brand);
    color: #fff;
    z-index: 10;
    font-weight: 600;
    font-size: 11px;
    padding: 6px 4px;
    max-width: 46px;
    vertical-align: bottom;
}
.fmt-label { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 130px; overflow: hidden; text-overflow: ellipsis; margin: 0 auto; color: rgba(255,255,255,.85); }
.grp-head { background: var(--brand-light) !important; text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #fff !important; padding: 5px; }
table.cube thead th.row-head { z-index: 15; background: var(--brand); }
.row-head {
    position: sticky;
    left: 0;
    background: var(--card);
    z-index: 5;
    text-align: left;
    padding: 7px 10px;
    white-space: nowrap;
    min-width: 220px;
}
.row-head .persona-name { font-weight: 700; color: var(--ink-alt); display: inline-flex; align-items: center; gap: 7px; }
.row-head .persona-name .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.row-head .angle-name { color: var(--muted); font-size: 12px; margin-top: 2px; }
.persona-band td.row-head { border-top: 2px solid var(--brand); }
tbody tr:hover td.row-head { background: var(--row-alt); }

td.cell {
    width: 30px;
    height: 30px;
    padding: 0;
    text-align: center;
    cursor: pointer;
    position: relative;
    background: var(--card);
}
td.cell:hover { background: var(--hover); }
td.cell .dot-mark {
    width: 15px; height: 15px;
    border-radius: 50%;
    margin: auto;
    background: var(--untested);
    transition: transform .08s ease;
}
td.cell:hover .dot-mark { transform: scale(1.28); }
td.cell.winner .dot-mark { background: var(--winner); }
td.cell.loser .dot-mark { background: var(--loser); }
td.cell.has-note::after {
    content: "";
    position: absolute;
    top: 3px; right: 3px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--note);
}

/* ---- Cell popover ---- */
.pop {
    position: absolute;
    z-index: 50;
    width: 280px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px;
    box-shadow: 0 12px 32px rgba(37,56,72,.18);
}
.pop-head { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.4; }
.pop-head b { color: var(--ink-alt); }
.pop-status { display: flex; gap: 6px; margin-bottom: 8px; }
.pop-btn { flex: 1; padding: 7px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-size: 12px; font-family: inherit; }
.pop-btn:hover { background: var(--hover); }
.pop-btn.active.pop-winner { background: var(--winner); border-color: var(--winner); color: #fff; font-weight: 700; }
.pop-btn.active.pop-loser { background: var(--loser); border-color: var(--loser); color: #fff; font-weight: 700; }
.pop-btn.active.pop-untested { background: var(--muted); border-color: var(--muted); color: #fff; font-weight: 700; }
.pop textarea { width: 100%; min-height: 64px; resize: vertical; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; font-family: inherit; font-size: 13px; }
.pop-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.pop-foot .muted { font-size: 11px; }

/* ---- Manage modal ---- */
.modal { position: fixed; inset: 0; background: rgba(37,56,72,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto; }
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 20px 50px rgba(37,56,72,.25); width: 780px; max-width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--ink-alt); }
.modal-body { padding: 18px; display: grid; grid-template-columns: 1fr; gap: 22px; }
.dim-block h3 { margin: 0 0 10px; font-size: 14px; color: var(--ink-alt); }
.dim-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.dim-row input[type=text] { flex: 1; min-width: 80px; }
.dim-row input[type=text], .dim-row textarea, .dim-row select {
    background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; font-family: inherit; font-size: 13px;
}
.dim-row .desc { flex: 1.4; }
.dim-row input[type=color] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.dim-add { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 15px; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }

.hidden { display: none !important; }

@media (max-width: 700px) {
    .filters { grid-template-columns: 1fr; }
    .topbar-title strong { font-size: 15px; }
}
