:root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #1e2235;
    --muted: #7b8096;
    --line: #e8eaf2;
    --primary: #5b3df5;
    --primary-soft: #efecff;
    --high: #e5484d; --high-bg: #fdecec;
    --medium: #f08a24; --medium-bg: #fff2e2;
    --low: #2fa56b; --low-bg: #e6f6ee;
    --progress: #3b6cf6; --progress-bg: #e8eefe;
    --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--text); background: var(--bg); font-size: 15px; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
a { color: var(--primary); text-decoration: none; }
.boot, .empty { padding: 2rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--card); border-right: 1px solid var(--line); padding: 1.25rem 1rem; flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.3rem; margin-bottom: 1.5rem; }
.logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 1rem; }
.nav-item { display: block; padding: .65rem .85rem; border-radius: 10px; color: var(--text); margin-bottom: .35rem; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-create { border: 1px solid var(--primary); color: var(--primary); }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 2rem; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.3rem; }
.user { display: flex; align-items: center; gap: .75rem; }
.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-info small { color: var(--muted); }
.content { padding: 1.5rem 2rem; }

.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-style: normal; font-size: .85rem; }
.avatar.sm { width: 26px; height: 26px; font-size: .7rem; }
.avatar.pending { background: var(--medium-bg); color: var(--medium); }

/* Cards & stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.stat { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .1rem; text-align: left; font: inherit; color: var(--text); cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.stat:hover { box-shadow: 0 4px 14px rgba(30,34,53,.08); }
.stat.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.stat.alert { border-color: var(--high); background: #fff8f8; }
.stat strong { font-size: 1.8rem; line-height: 1.1; }
.stat > span:not(.stat-icon) { color: var(--muted); font-size: .88rem; }
.stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 1.05rem; margin-bottom: .45rem; }
.stat-icon.blue { background: #e8f1ff; } .stat-icon.indigo { background: var(--primary-soft); } .stat-icon.amber { background: #fff4d6; }
.stat-icon.orange { background: var(--medium-bg); } .stat-icon.red { background: var(--high-bg); } .stat-icon.green { background: var(--low-bg); }
.progress-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.2rem; margin-bottom: 1.25rem; }
.progress-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .55rem; font-size: .92rem; color: var(--muted); }
.progress-head strong { color: var(--text); }
.progress-bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #8b73ff); border-radius: 999px; transition: width .4s; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.card.narrow { max-width: 720px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }

/* Tabs */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .9rem 0; }
.tab { border: 0; background: none; padding: .4rem .8rem; border-radius: 8px; color: var(--muted); cursor: pointer; font: inherit; }
.tab.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* Table */
.table { display: flex; flex-direction: column; gap: .5rem; overflow-x: auto; }
.row { display: grid; grid-template-columns: minmax(200px, 3fr) minmax(160px, 2fr) 90px 110px 130px; gap: .75rem; align-items: center; padding: .75rem 1rem; border-radius: 10px; }
.row.head { color: var(--muted); font-size: .85rem; padding-block: .25rem; }
.row:not(.head) { border: 1px solid var(--line); border-left: 4px solid var(--line); }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: #fafaff; }
.row.prio-high { border-left-color: var(--high); }
.row.prio-medium { border-left-color: var(--medium); }
.row.prio-low { border-left-color: var(--low); }
.title { font-weight: 600; }
.person { display: flex; align-items: center; gap: .5rem; }

/* Badges */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 6px; font-size: .8rem; font-weight: 500; background: var(--bg); color: var(--muted); }
.badge.high { background: var(--high-bg); color: var(--high); }
.badge.medium { background: var(--medium-bg); color: var(--medium); }
.badge.low { background: var(--low-bg); color: var(--low); }
.badge.st-progress { background: var(--progress-bg); color: var(--progress); }
.badge.st-review { background: var(--medium-bg); color: var(--medium); }
.badge.st-done { background: var(--low-bg); color: var(--low); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.form label, .field { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .9rem; }
.label { font-weight: 500; font-size: .9rem; }
.field > .badge { align-self: flex-start; }
.input { width: 100%; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea.input { resize: vertical; }
.input::placeholder { color: #a3a8bd; font-weight: 400; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.actions { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; }
.alert { background: var(--high-bg); color: var(--high); padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }

.btn { display: inline-block; border: 1px solid transparent; border-radius: 8px; padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4a2fe0; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-danger { background: var(--high-bg); color: var(--high); }

.seg { display: flex; gap: .5rem; flex-wrap: wrap; }
.seg-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .45rem .9rem; cursor: pointer; font: inherit; color: var(--text); }
.seg-btn.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.seg-btn.on.high { background: var(--high-bg); border-color: var(--high); color: var(--high); }
.seg-btn.on.medium { background: var(--medium-bg); border-color: var(--medium); color: var(--medium); }
.seg-btn.on.low { background: var(--low-bg); border-color: var(--low); color: var(--low); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { background: var(--primary-soft); color: var(--primary); padding: .2rem .6rem; border-radius: 999px; font-size: .85rem; }
.names { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar.more { background: var(--bg); color: var(--muted); }
.person { min-width: 0; }
.assignees { display: flex; flex-direction: column; gap: .5rem; margin: .25rem 0 1.25rem; }
.assignee { display: flex; align-items: center; gap: .6rem; }
.assignee .grow { flex: 1; }

/* Codes, deadlines, declined */
.code { display: block; color: var(--muted); font-size: .75rem; font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; }
.due-badge { display: inline-block; margin-left: .35rem; padding: .1rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.due-badge.soon { background: var(--medium-bg); color: var(--medium); }
.due-badge.overdue { background: var(--high-bg); color: var(--high); }
.row.due-soon { background: #fffaf3; }
.row.due-overdue { background: #fff6f6; }
.row.is-declined { opacity: .6; }
.badge.st-declined { background: var(--high-bg); color: var(--high); }
.section-gap { margin-top: 1.25rem; }
.info { background: var(--primary-soft); color: var(--primary); padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }
.devhint { background: #fff8e1; color: #8a6d00; border: 1px dashed #e6c200; padding: .5rem .75rem; border-radius: 8px; font-size: .85rem; margin-bottom: .5rem; }
.input.code { letter-spacing: .4em; font-size: 1.2rem; text-align: center; max-width: 11rem; }
.linkbtn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0 .25rem; }
.linkbtn.danger { color: var(--high); }
.linkbtn:disabled { opacity: .5; cursor: default; }
.search { max-width: 280px; }
.head-actions { display: flex; gap: .75rem; align-items: center; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 140px; }
.duration { display: flex; gap: .5rem; max-width: 260px; }
.contact { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; background: var(--bg); border-radius: 8px; }
.contact small { color: var(--low); }
/* User menu (top right) */
.usermenu { position: relative; }
.user-btn { display: flex; align-items: center; gap: .6rem; background: none; border: 1px solid transparent; border-radius: 12px; padding: .3rem .6rem .3rem .3rem; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.user-btn:hover { background: var(--bg); border-color: var(--line); }
.chev { color: var(--muted); font-size: .8rem; }
.menu-backdrop { position: fixed; inset: 0; z-index: 40; background: transparent; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 250px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(30,34,53,.15); z-index: 50; padding: .35rem; }
.menu-head { display: flex; flex-direction: column; padding: .6rem .75rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem; }
.menu-head small { color: var(--muted); }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .6rem .75rem; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text); }
.menu-item:hover { background: var(--bg); }
.menu-item.danger { color: var(--high); }
.menu-sep { height: 1px; background: var(--line); margin: .35rem 0; }

/* Map & location */
.map { width: 100%; border-radius: 10px; border: 1px solid var(--line); margin: .5rem 0 1rem; z-index: 0; }
.autocomplete { position: relative; }
.suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(30,34,53,.15); z-index: 40; overflow: hidden; }
.suggest { display: flex; gap: .5rem; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: .6rem .8rem; cursor: pointer; font: inherit; font-size: .9rem; color: var(--text); }
.suggest:last-child { border-bottom: 0; }
.suggest.active { background: var(--primary-soft); }
.suggest .pin { flex-shrink: 0; }
.suggest-info { padding: .65rem .8rem; color: var(--muted); font-size: .9rem; }
.suggest-info.error { color: var(--high); }
.chosen { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; background: var(--bg); border-radius: 8px; }
.place { color: var(--muted); }

/* Groups */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem; margin-top: 1rem; }
.group-card { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; }
.group-icon { font-size: 1.6rem; width: 44px; height: 44px; display: grid; place-items: center; background: var(--primary-soft); border-radius: 12px; }
.grow { flex: 1; min-width: 0; }
.editor { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; background: #fcfcff; }
.icons { display: flex; flex-wrap: wrap; gap: .4rem; }
.icon-btn { font-size: 1.3rem; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.icon-btn.on { border-color: var(--primary); background: var(--primary-soft); }
.member { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.chip.toggle { border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; font: inherit; font-size: .9rem; padding: .35rem .8rem; }
.chip.toggle.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Notifications */
.bell { position: relative; }
.bell-btn { position: relative; border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; }
.bell-badge { position: absolute; top: -6px; right: -6px; background: var(--high); color: #fff; font-size: .7rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.bell-menu { position: absolute; right: 0; top: 48px; width: 340px; max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(30,34,53,.15); z-index: 50; }
.bell-head { padding: .75rem 1rem; font-weight: 600; border-bottom: 1px solid var(--line); }
.note { padding: .7rem 1rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.note.unread { background: var(--primary-soft); }
.note.link { cursor: pointer; }
.note.link:hover { background: var(--bg); }

/* Task details */
.desc { white-space: pre-wrap; }
.meta { display: grid; grid-template-columns: 150px 1fr; gap: .4rem 1rem; margin: 1rem 0 1.25rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.field { margin-bottom: 1rem; }
.comment { display: flex; gap: .7rem; margin-bottom: .9rem; }
.comment p { margin: .15rem 0 0; }
.comment-form { display: flex; gap: .6rem; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 2rem; }
.auth-card .logo { margin-bottom: 1rem; }

#blazor-error-ui { color-scheme: light only; background: #fff3cd; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); box-sizing: border-box; display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* Mobile web */
@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; padding: .75rem 1rem; }
    .sidebar nav { display: flex; gap: .4rem; overflow-x: auto; }
    .nav-item { white-space: nowrap; margin: 0; }
    .logo { margin-bottom: .75rem; }
    .topbar, .content { padding: 1rem; }
    .user-info { display: none; }
    .row { grid-template-columns: 1fr 1fr; }
    .row.head { display: none; }
    .two { grid-template-columns: 1fr; }
}
