:root {
    --bg: #0f1420;
    --panel: #171d2b;
    --panel-2: #1f2738;
    --line: #2a3346;
    --text: #e6e9f0;
    --muted: #8b93a7;
    --accent: #4f7cff;
    --accent-2: #7c5cff;
    --ok: #2fbf71;
    --warn: #f4a340;
    --danger: #e5484d;
    --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }

.app-loading { padding: 3rem; text-align: center; color: var(--muted); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; background: var(--panel); border-right: 1px solid var(--line);
    padding: 1rem 0.75rem; flex-shrink: 0;
}
.brand { font-size: 1.4rem; font-weight: 700; color: var(--accent);
    padding: 0.25rem 0.5rem 1rem; letter-spacing: 1px; }
.nav-section { font-size: 0.7rem; text-transform: uppercase; color: var(--muted);
    margin: 1rem 0.5rem 0.25rem; letter-spacing: 1px; }
.nav-item {
    display: flex; gap: 0.5rem; align-items: center;
    padding: 0.5rem 0.6rem; border-radius: 8px; color: var(--text);
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--accent); color: #fff; }

.content { flex: 1; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.6rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); }
.bell { cursor: pointer; position: relative; }
.badge { background: var(--danger); color: #fff; border-radius: 10px;
    padding: 0 6px; font-size: 0.7rem; margin-left: 2px; }
.page-body { padding: 1.25rem; }

.auth-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }

/* ---------- Notifications ---------- */
.notif-panel {
    position: absolute; right: 1.25rem; top: 3rem; width: 340px; z-index: 40;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 0.5rem; box-shadow: 0 12px 40px rgba(0,0,0,.5); max-height: 70vh; overflow: auto;
}
.notif { padding: 0.6rem; border-radius: 8px; margin-bottom: 6px; background: var(--panel); }
.notif.reminder { border-left: 3px solid var(--warn); }
.notif .msg { color: var(--muted); white-space: pre-wrap; margin: 0.25rem 0; }
.notif .row { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Cards / forms ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.auth-card { width: 380px; }
h1, h2, h3 { margin-top: 0; }
.muted { color: var(--muted); }
label { display: block; margin: 0.6rem 0 0.2rem; color: var(--muted); font-size: 0.8rem; }
input, select, textarea {
    width: 100%; padding: 0.55rem 0.65rem; background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem;
}
/* Native checkboxes shouldn't inherit the full-width text-input treatment above. */
input[type="checkbox"], input[type="radio"] {
    width: auto; padding: 0; margin: 0;
    accent-color: var(--accent);
}

/* Give the browser's native date/time picker a hint to draw its calendar
   icon in a colour that stays visible on our dark background. */
input[type="date"], input[type="datetime-local"],
input[type="month"], input[type="week"], input[type="time"] {
    color-scheme: dark;
    cursor: pointer;
}
/* Chrome / Edge draw an inline calendar/clock icon — make it clearly visible. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(0.75);
    cursor: pointer;
}

/* Checklist / sub-tasks on a work item */
.checklist { list-style: none; padding: 0; margin: 0.4rem 0; }
.checklist li {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.35rem 0.25rem; border-bottom: 1px solid var(--line);
}
.checklist li:last-child { border-bottom: none; }
.checklist input[type="checkbox"] {
    width: 18px; height: 18px; flex: 0 0 18px; cursor: pointer;
}
.checklist .text { flex: 1; min-width: 0; word-break: break-word; }
.checklist .text.done { text-decoration: line-through; color: var(--muted); }
.checklist .completed-by { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.checklist .remove { color: var(--muted); background: none; border: none; cursor: pointer; padding: 0 0.2rem; }
.checklist .remove:hover { color: var(--danger); }
.checklist-add { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.checklist-add input { flex: 1; }
textarea { min-height: 90px; resize: vertical; }
.btn {
    display: inline-block; padding: 0.55rem 1rem; border-radius: 8px; border: none;
    background: var(--accent); color: #fff; cursor: pointer; font-size: 0.9rem;
}
.btn:hover { background: #3d6af0; }
.btn.secondary { background: var(--panel-2); border: 1px solid var(--line); }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--danger); }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; }
.error { color: var(--danger); margin-top: 0.5rem; }
.success { color: var(--ok); margin-top: 0.5rem; }
/* form validation */
.input-error { border-color: var(--danger) !important; box-shadow: 0 0 0 2px rgba(229,72,77,.25); }
.field-error { color: var(--danger); font-size: 0.78rem; margin-top: 0.2rem; }

/* rich text editor */
.rte { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.rte-toolbar { display: flex; gap: 2px; padding: 4px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.rte-toolbar button { background: var(--panel); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 0.8rem; }
.rte-toolbar button:hover { background: var(--accent); color: #fff; }
.rte-editor { min-height: 120px; padding: 0.6rem 0.7rem; outline: none; }
.rte-editor:empty:before { content: ""; }
.rendered-html :is(ul,ol) { padding-left: 1.2rem; margin: 0.3rem 0; }

/* work item priority backgrounds (P1 highest -> P5 lowest) */
.prio-p1 { background: rgba(229,72,77,.22) !important; border-color: rgba(229,72,77,.5) !important; }
.prio-p2 { background: rgba(244,120,64,.20) !important; border-color: rgba(244,120,64,.45) !important; }
.prio-p3 { background: rgba(244,196,64,.16) !important; border-color: rgba(244,196,64,.4) !important; }
.prio-p4 { background: rgba(79,124,255,.16) !important; border-color: rgba(79,124,255,.4) !important; }
.prio-p5 { background: rgba(120,124,140,.14) !important; }
.prio-tag { font-weight: 700; }
.prio-tag.prio-p1 { color: #ff6b70; }
.prio-tag.prio-p2 { color: #ff9d5c; }
.prio-tag.prio-p3 { color: #f4c440; }
.prio-tag.prio-p4 { color: #6f97ff; }
.prio-tag.prio-p5 { color: var(--muted); }
.full { width: 100%; }
.mt { margin-top: 1rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.grid { display: grid; gap: 1rem; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.pill { padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; background: var(--panel-2); }
.prio-critical { background: rgba(229,72,77,.2); color: #ff6b70; }
.prio-high { background: rgba(244,163,64,.2); color: #f4a340; }
.prio-medium { background: rgba(79,124,255,.2); color: #6f97ff; }
.prio-low { background: var(--panel-2); color: var(--muted); }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 0.75rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.column {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    min-width: 240px; width: 240px; flex-shrink: 0; padding: 0.5rem;
}
.column.drop-hover { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,124,255,.3) inset; }
.column-title { font-weight: 600; padding: 0.25rem 0.4rem 0.5rem; display: flex; justify-content: space-between; }
.column-title .count { color: var(--muted); }
.wi-card {
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
    padding: 0.6rem; margin-bottom: 0.5rem; cursor: grab;
}
.wi-card:active { cursor: grabbing; }
.wi-card .title { font-weight: 600; margin-bottom: 0.3rem; }
.wi-card .meta { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 0.75rem; }
.tag-bug { color: var(--danger); }
.tag-story { color: var(--accent-2); }
.chip { background: var(--bg); border: 1px solid var(--line); padding: 1px 7px; border-radius: 20px; }
.wi-actions { margin-top: 0.4rem; display: flex; gap: 0.5rem; }
.track-bar { margin-top: 0.5rem; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;
    border-top: 1px dashed var(--line); padding-top: 0.45rem; }
.track-bar .spent { font-size: 0.78rem; color: var(--muted); margin-right: auto; }
.track-btn { padding: 0.28rem 0.7rem; font-size: 0.78rem; }

/* ---------- Dashboard tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem; }
.tile .num { font-size: 1.8rem; font-weight: 700; }
.tile .lbl { color: var(--muted); }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #7a1a1a; color: #fff; padding: 0.6rem 1rem;
}

/* ---------- AI suggestions strip ---------- */
.suggest-panel {
    background: var(--panel); border: 1px solid var(--line);
    border-left: 3px solid var(--accent-2); border-radius: var(--radius);
    padding: 0.9rem 1rem; margin: 0.75rem 0 0.25rem;
}
.suggest-list { display: flex; gap: 0.75rem; overflow-x: auto; margin-top: 0.6rem; }
.suggest-card {
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
    padding: 0.7rem; min-width: 260px; width: 260px; flex-shrink: 0;
}
.suggest-card .title { font-weight: 600; margin-bottom: 0.35rem; }
.suggest-card .reason { color: var(--muted); font-size: 0.8rem; margin: 0.45rem 0; }
.suggest-card .btn { padding: 0.35rem 0.8rem; font-size: 0.82rem; }

/* ---------- Modal / popup ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
    width: 420px; max-width: 100%; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; }
.modal-close {
    background: none; border: none; color: var(--muted); font-size: 1.1rem;
    cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); }
