/* ==========================================================================
   Planara — core design system
   Tokens · base · layout (header, sidebar, content) · components
   Module-specific styles live in their own files in assets/css/.
   ========================================================================== */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-muted: #eef1f5;
  --bg-hover: #f0f3f7;
  --bg-active: #e6eefa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #dde2e9;
  --border-strong: #c5ccd6;
  --text: #1f2933;
  --text-muted: #5b6776;
  --text-faint: #8a96a6;
  --link: #1a67a3;
  --link-hover: #0f4c7c;

  --primary: #1a67a3;
  --primary-hover: #155487;
  --primary-soft: #e3effa;
  --primary-text: #ffffff;
  --accent: #35c53f;
  --danger: #c9302c;
  --danger-hover: #a52824;
  --danger-soft: #fdecec;
  --warning: #b97a00;
  --warning-soft: #fff5db;
  --success: #2c9e48;
  --success-soft: #e5f6ea;
  --info-soft: #e6f1fb;

  --header-bg: #102a43;
  --header-text: #e4ebf3;
  --header-hover: rgba(255, 255, 255, .1);
  --sidebar-bg: #f4f6f9;
  --sidebar-text: #2d3a48;
  --sidebar-hover: #e7ebf1;
  --sidebar-active-bg: #dce8f5;
  --sidebar-active-text: #0f4c7c;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 42, 67, .06);
  --shadow: 0 2px 8px rgba(16, 42, 67, .10), 0 1px 2px rgba(16, 42, 67, .06);
  --shadow-lg: 0 12px 32px rgba(16, 42, 67, .18), 0 2px 6px rgba(16, 42, 67, .08);

  --header-h: 52px;
  --sidebar-w: 248px;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1720; --bg-subtle: #151f2b; --bg-muted: #1b2633; --bg-hover: #1d2936; --bg-active: #1c3350;
    --surface: #131c27; --surface-raised: #182230; --border: #2a3644; --border-strong: #3a4757;
    --text: #e3e9f0; --text-muted: #a3b0bf; --text-faint: #7a8797; --link: #6fb1ea; --link-hover: #9ccaf2;
    --primary: #2f84c9; --primary-hover: #3b93db; --primary-soft: #16314b; --danger: #e5534b; --danger-hover: #f06a63;
    --danger-soft: #3a1d1d; --warning: #e0a33b; --warning-soft: #33280f; --success: #3fb55d; --success-soft: #16301f; --info-soft: #14283c;
    --header-bg: #0a1621; --sidebar-bg: #121b26; --sidebar-text: #c9d4df; --sidebar-hover: #1a2531; --sidebar-active-bg: #1c3350; --sidebar-active-text: #9ccaf2;
    --shadow: 0 2px 10px rgba(0,0,0,.45); --shadow-lg: 0 14px 36px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1720; --bg-subtle: #151f2b; --bg-muted: #1b2633; --bg-hover: #1d2936; --bg-active: #1c3350;
  --surface: #131c27; --surface-raised: #182230; --border: #2a3644; --border-strong: #3a4757;
  --text: #e3e9f0; --text-muted: #a3b0bf; --text-faint: #7a8797; --link: #6fb1ea; --link-hover: #9ccaf2;
  --primary: #2f84c9; --primary-hover: #3b93db; --primary-soft: #16314b; --danger: #e5534b; --danger-hover: #f06a63;
  --danger-soft: #3a1d1d; --warning: #e0a33b; --warning-soft: #33280f; --success: #3fb55d; --success-soft: #16301f; --info-soft: #14283c;
  --header-bg: #0a1621; --sidebar-bg: #121b26; --sidebar-text: #c9d4df; --sidebar-hover: #1a2531; --sidebar-active-bg: #1c3350; --sidebar-active-text: #9ccaf2;
  --shadow: 0 2px 10px rgba(0,0,0,.45); --shadow-lg: 0 14px 36px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin: 0 0 .6em; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, pre, kbd { font-family: var(--mono); font-size: .92em; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; background: var(--bg-subtle); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.icon { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }
.icon-lg .icon, .icon.icon-lg { width: 20px; height: 20px; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.gap-sm { gap: 6px !important; }
::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }

/* ---------- App shell ---------- */
.app-header {
  position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 50;
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
  background: var(--header-bg); color: var(--header-text);
}
.app-header a, .app-header button { color: var(--header-text); }
.header-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px;
  border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; font: inherit; font-size: .95rem; position: relative;
}
.header-btn:hover { background: var(--header-hover); text-decoration: none; }
.header-btn .icon { width: 18px; height: 18px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.08rem; letter-spacing: .2px; padding: 0 8px; height: 36px; border-radius: var(--radius); }
.brand:hover { text-decoration: none; background: var(--header-hover); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #3aa0ff, #35c53f); display: inline-grid; place-items: center; color: #fff; }
.brand-mark .icon { width: 17px; height: 17px; stroke-width: 2.4; }
.header-project-btn { max-width: 280px; }
.header-project-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-search { flex: 1 1 auto; max-width: 520px; margin: 0 auto; position: relative; }
.header-search input {
  width: 100%; height: 34px; border-radius: 17px; border: 1px solid rgba(255,255,255,.18); padding: 0 14px 0 36px;
  background: rgba(255,255,255,.08); color: #fff; font: inherit;
}
.header-search input::placeholder { color: rgba(228,235,243,.65); }
.header-search input:focus { outline: none; background: #fff; color: #1f2933; border-color: #fff; }
.header-search .icon { position: absolute; left: 12px; top: 9px; color: rgba(228,235,243,.75); }
.header-search input:focus + .icon, .header-search:focus-within .icon { color: #5b6776; }
.header-right { display: flex; align-items: center; gap: 2px; }
.notif-count {
  position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; border-radius: 9px; padding: 0 4px;
  background: #e5534b; color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.app-body { display: flex; padding-top: var(--header-h); min-height: 100vh; }
.app-sidebar {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 30;
  background: var(--sidebar-bg); border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 8px 24px;
  transition: transform .18s ease;
}
.app-main { flex: 1 1 auto; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .18s ease; }
body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .app-main { margin-left: 0; }
body.no-sidebar .app-sidebar { display: none; }
body.no-sidebar .app-main { margin-left: 0; }
.content { padding: 20px var(--gutter) 48px; max-width: 1600px; }
body.full-width .content { max-width: none; }
body.flush .content { padding: 0; }

.sidebar-project {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border);
}
.sidebar-project-avatar {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: hsl(var(--h, 210) 55% 45%); color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar-project-name { font-weight: 600; line-height: 1.25; word-break: break-word; }
.sidebar-project-name a { color: var(--text); }
.sidebar-section-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .6px; color: var(--text-faint); padding: 14px 10px 6px; font-weight: 600; }
.sidebar-nav { list-style: none; margin: 0; padding: 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius); color: var(--sidebar-text);
  font-size: .97rem; position: relative;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); text-decoration: none; }
.sidebar-nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-nav a.active::before { content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.sidebar-nav .icon { width: 17px; height: 17px; opacity: .85; }
.sidebar-subnav { list-style: none; margin: 2px 0 6px 27px; padding: 0 0 0 8px; border-left: 1px solid var(--border); }
.sidebar-subnav a { padding: 4px 8px; font-size: .92rem; }
.sidebar-subnav a.active::before { display: none; }

/* ---------- Page header ---------- */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: .88rem; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs .sep { color: var(--text-faint); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header h1 { margin: 0; font-size: 1.6rem; word-break: break-word; }
.page-header .subtitle { color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.toolbar .spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.btn:focus-visible, .input:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); color: #fff; background: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.btn-danger-outline:hover { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { height: 28px; padding: 0 10px; font-size: .9rem; }
.btn-xs { height: 24px; padding: 0 7px; font-size: .84rem; gap: 4px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 1.05rem; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-icon.btn-xs { width: 24px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn:first-child, .btn-group > form:first-child .btn { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group > .btn:last-child, .btn-group > form:last-child .btn { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group > .btn.active { background: var(--bg-active); border-color: var(--primary); color: var(--primary); position: relative; z-index: 1; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font: inherit; }
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }

/* ---------- Forms ---------- */
.input, select.input, textarea.input {
  display: block; width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; line-height: 1.4;
}
textarea.input { min-height: 90px; resize: vertical; }
select.input { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a96a6' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
select.input[multiple] { background-image: none; padding-right: 10px; min-height: 90px; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.input-sm { min-height: 28px; padding: 3px 8px; font-size: .92rem; }
.input-inline { display: inline-block; width: auto; }
.input.is-invalid { border-color: var(--danger); }
.form { max-width: 860px; }
.form-wide { max-width: none; }
.form-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 6px 20px; align-items: start; margin-bottom: 14px; }
.form-label { font-weight: 500; padding-top: 7px; color: var(--text); }
.form-field { min-width: 0; }
.form-hint { color: var(--text-muted); font-size: .87rem; margin-top: 4px; }
.form-stacked .form-row { grid-template-columns: 1fr; gap: 4px; }
.form-stacked .form-label { padding-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.form-actions { display: flex; gap: 8px; align-items: center; padding-top: 10px; margin-top: 10px; flex-wrap: wrap; }
.form-section { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px 6px; margin-bottom: 20px; background: var(--surface); }
.form-section > h3, .form-section > legend { font-size: 1.02rem; margin: 0 0 14px; padding: 0; }
fieldset.form-section { min-width: 0; }
.required { color: var(--danger); }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; margin-right: 14px; padding: 4px 0; }
.checkbox input, .radio input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 16px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.color-input { display: inline-flex; align-items: center; gap: 8px; }
.color-input input[type=color] { width: 40px; height: 34px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.errors { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
.errors ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------- Flash / callouts ---------- */
.flashes { position: fixed; top: calc(var(--header-h) + 12px); right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(460px, calc(100vw - 32px)); }
.flash {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  background: var(--surface-raised); border-left: 4px solid var(--primary); animation: flash-in .25s ease;
}
.flash-success { border-left-color: var(--success); }
.flash-error { border-left-color: var(--danger); }
.flash-warning { border-left-color: var(--warning); }
.flash .flash-close { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--text-muted); padding: 0; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.callout { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--bg-subtle); display: flex; gap: 10px; align-items: flex-start; }
.callout-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.callout-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.callout-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.callout-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.announcement { background: var(--warning-soft); border-bottom: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); padding: 8px var(--gutter); }

/* ---------- Cards / boxes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; font-size: 1.02rem; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }
.stat { padding: 16px; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: .9rem; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { width: 44px; height: 44px; color: var(--text-faint); margin-bottom: 10px; stroke-width: 1.5; }
.empty-state h3 { color: var(--text); }
.definition-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.definition-list dt { color: var(--text-muted); }
.definition-list dd { margin: 0; min-width: 0; word-break: break-word; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .96rem; }
.table th, .table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--bg-subtle); font-weight: 600; color: var(--text-muted); font-size: .84rem; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; width: 1%; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.group-row td { background: var(--bg-muted); font-weight: 600; }
.table tr.sum-row td { background: var(--bg-subtle); font-weight: 600; }
.table tr.selected td { background: var(--bg-active); }
.table-compact th, .table-compact td { padding: 5px 10px; }
.sort-link { color: inherit; }
.sort-link.active { color: var(--primary); }

/* ---------- Badges, labels, avatars ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px; border-radius: 11px; font-size: .8rem; font-weight: 600; background: var(--bg-muted); color: var(--text-muted); white-space: nowrap; }
.badge-colored { background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 82%, var(--text)); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.counter { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bg-muted); color: var(--text-muted); font-size: .78rem; font-weight: 700; }
.type-label { font-weight: 700; font-size: .8rem; letter-spacing: .3px; color: color-mix(in srgb, var(--c) 85%, var(--text)); white-space: nowrap; }
.status-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px; border-radius: 11px; font-size: .84rem; font-weight: 500; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text);
}
.status-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.priority-label { display: inline-flex; align-items: center; gap: 6px; }
.priority-dot { width: 9px; height: 9px; border-radius: 2px; background: var(--c, #999); transform: rotate(45deg); }
.avatar {
  display: inline-grid; place-items: center; border-radius: 50%; flex-shrink: 0; font-weight: 600; color: #fff; user-select: none;
  background: hsl(var(--h, 210) 50% 46%); vertical-align: middle; letter-spacing: -.3px;
}
.avatar-xs { width: 18px; height: 18px; font-size: 8.5px; }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-md { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }
.avatar-xl { width: 72px; height: 72px; font-size: 26px; }
.avatar-group { border-radius: 30%; }
.avatar-placeholder { background: transparent; color: var(--text-muted); border: 1.5px dashed var(--text-faint); }
.user-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.user-link:hover { color: var(--link); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.progress { display: inline-block; width: 90px; height: 7px; background: var(--bg-muted); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.progress-fill { display: block; height: 100%; background: var(--success); border-radius: 4px; }
.progress-label { font-size: .84rem; color: var(--text-muted); }
.progress-wide .progress { width: 100%; height: 10px; }
.color-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--c); vertical-align: -2px; border: 1px solid rgba(0,0,0,.1); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; color: var(--text-muted); border: 0; background: none; font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs a.active, .tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 120; min-width: 210px; max-width: 360px; max-height: 70vh; overflow-y: auto;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 5px; display: none;
}
.dropdown-menu.align-right { left: auto; right: 0; }
.dropdown.open > .dropdown-menu { display: block; animation: menu-in .12s ease; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dropdown-menu a, .dropdown-menu button, .dropdown-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--text) !important; font: inherit; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dropdown-menu a:hover, .dropdown-menu button:hover, .dropdown-item:hover { background: var(--bg-hover); text-decoration: none; }
.dropdown-menu .danger { color: var(--danger) !important; }
.dropdown-menu .divider { height: 1px; background: var(--border); margin: 5px 2px; }
.dropdown-menu .menu-title { padding: 6px 10px 4px; font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); font-weight: 600; }
.dropdown-menu form { margin: 0; }
.dropdown-menu .active { background: var(--bg-active); font-weight: 600; }
.dropdown-search { padding: 4px 4px 6px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 22, 33, .5); z-index: 300; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; overflow-y: auto; }
.modal { background: var(--surface-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: modal-in .16s ease; }
.modal-lg { max-width: 820px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 18px 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@keyframes modal-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0; color: var(--text-muted); font-size: .92rem; }
.pagination-pages, .pagination-per-page { display: flex; gap: 2px; align-items: center; }
.pagination-per-page { margin-left: auto; }
.pagination a, .pagination-current, .pagination-gap { min-width: 30px; height: 28px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); }
.pagination a:hover { background: var(--bg-hover); text-decoration: none; }
.pagination-current { background: var(--primary-soft); color: var(--primary); font-weight: 700; }

/* ---------- Activity / journals ---------- */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-day { font-weight: 600; margin: 22px 0 8px; color: var(--text-muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .4px; }
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: 0; }
.activity-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-muted); color: var(--text-muted); flex-shrink: 0; }
.activity-body { min-width: 0; flex: 1; }
.activity-title { font-weight: 500; }
.activity-meta { color: var(--text-muted); font-size: .88rem; }
.journal { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.journal:first-child { border-top: 0; }
.journal-main { flex: 1; min-width: 0; }
.journal-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.journal-header .author { font-weight: 600; color: var(--text); }
.journal-header .when { color: var(--text-muted); font-size: .88rem; }
.journal-header .journal-actions { margin-left: auto; display: flex; gap: 2px; opacity: .2; transition: opacity .12s; }
.journal:hover .journal-actions { opacity: 1; }
.journal-details { list-style: none; margin: 4px 0 0; padding: 0; color: var(--text-muted); font-size: .93rem; }
.journal-details li { padding: 1px 0; }
.journal-details em { font-style: normal; color: var(--text); }
.journal-notes { margin-top: 6px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.journal.internal .journal-notes { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .86rem; }
.reaction.mine { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- Markdown ---------- */
.markdown { word-wrap: break-word; line-height: 1.6; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin-top: 1.2em; position: relative; }
.markdown h1:first-child, .markdown h2:first-child, .markdown h3:first-child { margin-top: 0; }
.markdown .heading-anchor { margin-left: 6px; color: var(--text-faint); opacity: 0; font-weight: 400; }
.markdown h1:hover .heading-anchor, .markdown h2:hover .heading-anchor, .markdown h3:hover .heading-anchor, .markdown h4:hover .heading-anchor { opacity: 1; }
.markdown ul, .markdown ol { padding-left: 1.6em; margin: 0 0 1em; }
.markdown li + li { margin-top: .2em; }
.markdown .task-list { list-style: none; padding-left: .4em; }
.markdown .task-item input { margin-right: 6px; vertical-align: -1px; }
.markdown blockquote { margin: 0 0 1em; padding: 4px 16px; border-left: 4px solid var(--border-strong); color: var(--text-muted); }
.markdown code { background: var(--bg-muted); padding: 1px 5px; border-radius: 4px; }
.markdown pre.code-block { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; margin: 0 0 1em; }
.markdown pre code { background: none; padding: 0; }
.markdown .md-table, .markdown table { border-collapse: collapse; margin: 0 0 1em; }
.markdown .table-wrap { border-radius: var(--radius); display: inline-block; max-width: 100%; margin-bottom: 1em; }
.markdown .table-wrap .md-table { margin: 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown th { background: var(--bg-subtle); }
.markdown img { border-radius: var(--radius-sm); }
.markdown mark { background: #ffe58a; color: #1f2933; padding: 0 2px; border-radius: 2px; }
.md-toc { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 1em; display: inline-block; min-width: 240px; }
.md-toc ul { list-style: none; padding: 0; margin: 4px 0 0; }
.md-toc-title { font-weight: 600; }
.wp-ref { font-weight: 500; }
.wp-ref-closed { text-decoration: line-through; }
.wp-ref-detailed { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.wiki-link-new { color: var(--danger); }
.mention { background: var(--primary-soft); border-radius: 4px; padding: 0 3px; }

/* ---------- Markdown editor ---------- */
.editor { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.editor-toolbar { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; padding: 4px 6px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); border-radius: var(--radius) var(--radius) 0 0; }
.editor-toolbar button { width: 28px; height: 28px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted); display: inline-grid; place-items: center; }
.editor-toolbar button:hover { background: var(--bg-hover); color: var(--text); }
.editor-toolbar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.editor-toolbar .editor-tabs { margin-left: auto; display: flex; gap: 2px; }
.editor-toolbar .editor-tabs button { width: auto; padding: 0 10px; font: inherit; font-size: .86rem; }
.editor-toolbar .editor-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.editor textarea { border: 0 !important; box-shadow: none !important; border-radius: 0 0 var(--radius) var(--radius); min-height: 140px; font-family: var(--font); }
.editor-preview { padding: 10px 12px; min-height: 140px; }
.editor-footer { display: flex; justify-content: space-between; gap: 8px; padding: 4px 10px; font-size: .8rem; color: var(--text-faint); border-top: 1px dashed var(--border); }
.editor.dragover { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- Autocomplete ---------- */
.ac-menu { position: absolute; z-index: 400; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; min-width: 240px; max-width: 420px; max-height: 300px; overflow-y: auto; }
.ac-item { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: var(--radius-sm); cursor: pointer; }
.ac-item.active, .ac-item:hover { background: var(--bg-active); }
.ac-item .ac-sub { color: var(--text-muted); font-size: .85rem; margin-left: auto; }
.ac-empty { padding: 8px 10px; color: var(--text-muted); }
.ac-wrap { position: relative; }

/* ---------- Attachments ---------- */
.attachments-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.attachment { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.attachment .meta { color: var(--text-muted); font-size: .85rem; margin-left: auto; white-space: nowrap; }
.attachment-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.attachment-thumb { width: 96px; height: 72px; border-radius: var(--radius); border: 1px solid var(--border); object-fit: cover; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--text-muted); cursor: pointer; transition: background .12s, border-color .12s; }
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- Filters panel ---------- */
.filters { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 14px; }
.filter-row { display: grid; grid-template-columns: 180px 160px minmax(0, 1fr) 32px; gap: 8px; align-items: center; margin-bottom: 8px; }
.filter-row .filter-label { font-weight: 500; }
.filter-values { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-values select[multiple] { min-height: 34px; height: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); font-size: .87rem; font-weight: 500; }
.chip button, .chip a { border: 0; background: none; color: inherit; cursor: pointer; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; }
.chip button:hover, .chip a:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }

/* ---------- Misc ---------- */
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-plain > li:last-child { border-bottom: 0; }
.tree-toggle { width: 18px; height: 18px; display: inline-grid; place-items: center; border: 0; background: none; cursor: pointer; color: var(--text-muted); padding: 0; border-radius: 3px; }
.tree-toggle:hover { background: var(--bg-hover); }
.tooltip { position: relative; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.sticky-top { position: sticky; top: calc(var(--header-h) + 12px); }
.key-value { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.key-value:last-child { border-bottom: 0; }
.key-value .k { width: 40%; color: var(--text-muted); flex-shrink: 0; }
.key-value .v { flex: 1; min-width: 0; word-break: break-word; }
.diff { font-family: var(--mono); font-size: .9rem; white-space: pre-wrap; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.diff .line { padding: 1px 10px; }
.diff .ins { background: #e6ffec; color: #116329; }
.diff .del { background: #ffebe9; color: #82071e; text-decoration: line-through; }
:root[data-theme="dark"] .diff .ins { background: #12321d; color: #7ee2a0; }
:root[data-theme="dark"] .diff .del { background: #3b1518; color: #ff9b95; }
.inline-edit { cursor: pointer; border-radius: var(--radius-sm); padding: 2px 6px; margin: -2px -6px; display: inline-block; min-width: 40px; min-height: 22px; }
.inline-edit:hover { background: var(--bg-hover); box-shadow: inset 0 0 0 1px var(--border); }
.skeleton { background: linear-gradient(90deg, var(--bg-muted), var(--bg-hover), var(--bg-muted)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.footer { color: var(--text-faint); font-size: .85rem; padding: 18px var(--gutter); border-top: 1px solid var(--border); }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #1a67a333, transparent), radial-gradient(900px 500px at 110% 110%, #35c53f22, transparent), var(--bg-subtle); }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 30px 32px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 1.25rem; font-weight: 700; color: var(--text); }
.auth-brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: 4px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: .92rem; }
.code-input { letter-spacing: 6px; font-size: 1.4rem; text-align: center; font-family: var(--mono); }

/* ---------- Print ---------- */
@media print {
  .app-header, .app-sidebar, .page-actions, .toolbar, .flashes, .footer, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  .app-body { padding: 0; }
  .content { padding: 0; max-width: none; }
  a { color: inherit; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .app-sidebar { transform: none; }
  .app-main { margin-left: 0; }
  .header-search { display: none; }
  .header-project-btn span { display: none; }
  .grid-2, .grid-3, .grid-4, .split, .form-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 4px; }
  .form-label { padding-top: 0; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-row .filter-values { grid-column: 1 / -1; }
  .brand-text { display: none; }
}
@media (min-width: 901px) { .sidebar-backdrop { display: none !important; } }
.sidebar-backdrop { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 25; display: none; }
body.sidebar-open .sidebar-backdrop { display: block; }
.reaction-picker { min-width: auto !important; }
.dropdown.open > .reaction-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.reaction-picker button { justify-content: center; font-size: 18px; padding: 6px; }
.markdown th { text-transform: none; letter-spacing: 0; font-size: inherit; color: var(--text); position: static; }
/* Long translations: let the work package side tabs wrap instead of scrolling */
.wp-tabs { flex-wrap: wrap; row-gap: 0; }
