:root {
  color-scheme: light;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #162239;
  background: #f5f7fb;
  --ink: #162239;
  --muted: #53637a;
  --line: #dfe5ef;
  --blue: #284fc3;
  --blue-dark: #2343a4;
  --blue-soft: #eaf0ff;
  --paper: #fff;
  --radius: 16px;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
body, button, input, textarea, select { font-size: 1rem; }
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #5576db; outline-offset: 3px; }
svg { display: block; width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
h1, h2, p { margin: 0; }
.view:focus { outline: none; }
.shell { min-height: 100dvh; }
.sidebar { display: contents; }
.sidebar > .brand, .sidebar-foot, .topbar-date, .nav-full { display: none; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 750; letter-spacing: -.035em; white-space: nowrap; }
.brand-icon { display: grid; place-items: center; width: 2.125rem; height: 2.125rem; border-radius: .68rem; color: #fff; background: var(--blue); }
.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem; min-height: 4.25rem; padding: .65rem 1rem; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-actions { margin-left: auto; }
.topbar .button { font-size: .875rem; padding-inline: .7rem; white-space: nowrap; }
.topbar .button svg { width: 1.05rem; height: 1.05rem; }

.navigation {
  z-index: 5;
  position: fixed;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: .32rem .35rem calc(.32rem + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.navigation a { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .25rem; min-height: 3.35rem; border-radius: .8rem; color: var(--muted); font-size: .875rem; font-weight: 650; }
.navigation a:hover { background: #f3f6fb; }
.navigation a[aria-current="page"] { color: var(--blue-dark); background: var(--blue-soft); }
.view { max-width: 74rem; margin: 0 auto; padding: 1.45rem 1rem calc(5.1rem + env(safe-area-inset-bottom)); }
.page-head { margin-bottom: 1.2rem; }
h1 { font-size: clamp(2rem, 5vw, 2.65rem); line-height: 1.08; letter-spacing: -.055em; }
.page-head p { margin-top: .42rem; color: var(--muted); font-size: 1rem; line-height: 1.45; }

.brief { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .72rem; align-items: center; border: 1px solid #ccd9fb; border-radius: var(--radius); padding: .8rem; background: #eaf0ff; color: #1c3781; }
.brief-icon { display: grid; place-items: center; width: 2.5rem; aspect-ratio: 1; border-radius: .85rem; background: #fff; color: var(--blue); }
.brief h2, .group h2, .rule-card h2, .rule-preview h2 { font-size: 1rem; line-height: 1.35; }
.brief p { margin-top: .15rem; font-size: .875rem; color: #41547b; line-height: 1.35; }
.brief-count { display: grid; justify-items: end; border-left: 1px solid #c6d5f7; padding-left: .75rem; white-space: nowrap; }
.brief-count strong { font-size: 1.55rem; line-height: 1; }
.brief-count span { font-size: .875rem; color: #41547b; margin-top: .15rem; }

.group { margin-top: 1.15rem; }
.group-heading { display: flex; align-items: center; gap: .55rem; margin-bottom: .45rem; }
.count { display: grid; place-items: center; min-width: 1.55rem; padding: .1rem .35rem; border-radius: 1rem; background: #e8edf5; color: #415270; font-size: .875rem; font-weight: 700; }
.entries { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: 'title title chevron' 'next next next' 'side side side';
  align-items: center;
  gap: .3rem .55rem;
  list-style: none;
  padding: .72rem .82rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.entry-summary:focus-visible { outline-offset: -4px; }
.entry-summary:hover { background: #f9fbfe; }
.entry-summary::-webkit-details-marker { display: none; }
.entry-title { grid-area: title; display: grid; gap: .12rem; min-width: 0; line-height: 1.3; }
.entry-title strong { font-size: 1rem; font-weight: 720; }
.entry-area { color: var(--muted); font-size: .875rem; }
.entry-next { grid-area: next; color: #41516b; line-height: 1.35; }
.entry-status { display: block; color: #3e5482; font-size: .875rem; font-weight: 650; margin-bottom: .12rem; }
.entry-side { grid-area: side; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; min-width: 0; font-size: .875rem; }
.entry-chevron { grid-area: chevron; align-self: start; color: #506684; }
details[open] > summary .entry-chevron { transform: rotate(90deg); }
.entry-date { color: var(--muted); }
.entry-date.overdue { color: #a62737; font-weight: 650; }
.entry-amount { font-weight: 700; color: #263652; }
.priority { display: inline-block; font-weight: 700; border-radius: .4rem; padding: .1rem .43rem; background: #edf1f8; color: #3a4e70; }
.priority.high { background: #fff0e9; color: #963a19; }
.priority.low { background: #e9f6ef; color: #285d43; }
.entry-detail { padding: .8rem .9rem 1rem; border-top: 1px solid #e7ebf3; background: #fbfcff; overflow-wrap: anywhere; }
.tree, .tree ul { margin: 0; padding-left: 1rem; }
.tree { list-style: none; padding-left: 0; color: var(--muted); }
.tree > li + li { margin-top: .6rem; }
.tree strong { color: var(--ink); }
.tree ul { margin-top: .2rem; list-style: none; border-left: 2px solid #dae4f4; white-space: pre-wrap; }
.tree li { line-height: 1.4; }
.entry-actions, .rule-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.empty { margin-top: 1rem; color: var(--muted); padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }

.button { min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; gap: .38rem; padding: .49rem .76rem; border: 1px solid transparent; border-radius: .65rem; font-weight: 650; font-size: .9375rem; line-height: 1.2; text-align: center; }
.button.primary { color: #fff; background: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: #23417f; border-color: #d3deee; background: var(--paper); }
.button.secondary:hover { background: #f0f5ff; }
.button:disabled { opacity: .65; cursor: default; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: 1rem; }
.filters button { min-height: 2.75rem; border: 1px solid var(--line); border-radius: .65rem; padding: .42rem .7rem; background: var(--paper); color: var(--muted); font-size: .875rem; font-weight: 650; }
.filters button[aria-pressed="true"] { color: var(--blue-dark); border-color: #c8d6ff; background: var(--blue-soft); }
.cases-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .8rem; }
.cases-toolbar .filters { margin: 0; }
.case-date-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; color: var(--muted); font-size: .875rem; font-weight: 650; }
.case-date-filter select { width: auto; max-width: 100%; font-size: .875rem; }
.case-group { margin-top: 1.15rem; }
.case-group h2 { font-size: 1rem; line-height: 1.35; }
.case-table-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.case-table { display: block; width: 100%; border-collapse: collapse; line-height: 1.35; }
.case-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.case-table tbody { display: block; }
.case-table .case-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas: 'title title' 'next next' 'deadline control';
  align-items: start;
  gap: .45rem .8rem;
  padding: .65rem .8rem .8rem;
}
.case-detail-row + .case-row { border-top: 1px solid var(--line); }
.case-table td { min-width: 0; padding: 0; overflow-wrap: anywhere; }
.case-title-cell { grid-area: title; }
.case-next-cell { grid-area: next; color: #41516b; }
.case-deadline-cell { grid-area: deadline; }
.case-control-cell { grid-area: control; color: var(--muted); }
.case-open { display: flex; width: 100%; min-height: 2.75rem; padding: .05rem 0; align-items: center; justify-content: space-between; gap: .4rem; border: 0; border-radius: .35rem; background: transparent; color: var(--ink); text-align: left; font-weight: 720; line-height: 1.3; overflow-wrap: anywhere; }
.case-open:hover { color: var(--blue-dark); }
.case-open > svg, .case-open-icon { color: #506684; flex-shrink: 0; }
.case-open[aria-expanded="true"] > svg, .case-open[aria-expanded="true"] .case-open-icon { transform: rotate(90deg); }
.case-area, .case-status, .case-mobile-label { display: block; color: var(--muted); font-size: .875rem; }
.case-status { color: #3e5482; font-weight: 650; margin-bottom: .12rem; }
.case-mobile-label { margin-bottom: .15rem; }
.case-deadline { font-weight: 700; }
.case-deadline-cell, .case-control-cell { font-size: .9375rem; }
.case-overdue { color: #a62737; font-weight: 700; }
.case-detail-row, .case-detail-row td { display: block; }
.case-detail-row[hidden] { display: none; }
.case-detail-row:last-child .entry-detail { border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); }

.calendar-toggle { margin-bottom: .85rem; }
.calendar-toggle .filters { margin-top: 0; }
.calendar { min-width: 0; padding: .55rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.calendar-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem; margin-bottom: .5rem; padding-inline: .15rem; }
.calendar-head h2 { font-size: clamp(1rem, 3.6vw, 1.25rem); line-height: 1.3; overflow-wrap: anywhere; }
.calendar-head button { min-width: 2.5rem; min-height: 2.5rem; padding: .35rem .55rem; }
.calendar-table-wrap { max-width: 100%; max-height: min(25rem, 58dvh); margin-top: .7rem; overflow: auto; border: 1px solid var(--line); border-radius: .7rem; scroll-padding: 3.25rem .3rem .3rem 6rem; }
.calendar-table-wrap:focus-visible { outline: 3px solid #5576db; outline-offset: 2px; }
.calendar-table { width: 100%; min-width: 35rem; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: .875rem; line-height: 1.35; }
.calendar-table th, .calendar-table td { padding: 0; border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; overflow-wrap: anywhere; }
.calendar-table :is(th, td):last-child { border-inline-end: 0; }
.calendar-table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.calendar-table thead th { position: sticky; inset-block-start: 0; z-index: 2; padding: .6rem; background: #edf2fc; color: #384c70; }
.calendar-table thead th:first-child, .calendar-day-cell { position: sticky; inset-inline-start: 0; width: 5.65rem; }
.calendar-table thead th:first-child { z-index: 3; }
.calendar-day-cell { z-index: 1; background: #f5f7fb; color: #384c70; font-weight: 700; }
.calendar-table .calendar-day-cell { padding: .52rem .6rem; }
.calendar-table th:has(.calendar-filter-trigger) { padding: 0; }
.calendar-table tr[aria-current="date"] .calendar-day-cell, .calendar-day-cell[aria-current="date"], .calendar-day-cell [aria-current="date"] { background: #e4edff; color: var(--blue-dark); }
.calendar-cell, .calendar-filter-trigger { display: flex; width: 100%; min-height: 2.75rem; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: .3rem; padding: .4rem; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; overflow-wrap: anywhere; }
.calendar-filter-trigger { padding: .52rem .6rem; font-weight: 700; }
.calendar-day-cell .calendar-filter-trigger { flex-direction: row; align-items: center; white-space: nowrap; }
.calendar-cell > span { display: grid; gap: .25rem; min-width: 0; }
.calendar-scroll-hint { display: none; }
@media (max-width: 41rem) {
  .calendar-scroll-hint { display: block; margin-top: .55rem; color: var(--muted); font-size: .875rem; }
  .calendar-table-wrap { max-height: min(22rem, 43dvh); margin-top: .4rem; }
}
.calendar-cell-title { display: block; max-width: 100%; padding: .25rem .35rem; border-radius: .32rem; background: var(--blue-soft); color: #233e80; font-weight: 650; overflow-wrap: anywhere; }
.calendar-cell:hover, .calendar-filter-trigger:hover { background: #f0f5ff; }
.calendar-cell:focus-visible, .calendar-filter-trigger:focus-visible { outline-offset: -3px; }
.calendar-cell[aria-pressed="true"], .calendar-filter-trigger[aria-pressed="true"] { background: var(--blue); color: #fff; }
.calendar-cell[aria-pressed="true"] .calendar-cell-title { background: #f4f7ff; }
.calendar-empty-cell { display: block; padding: .25rem .2rem; color: var(--muted); }
.calendar-cell[aria-pressed="true"] .calendar-empty-cell { color: #fff; }
.calendar-agenda { margin-top: .8rem; padding: .7rem .25rem .15rem; border-top: 1px solid var(--line); }
.calendar-agenda h2, .calendar-agenda h3 { margin: 0 0 .45rem; font-size: 1rem; line-height: 1.35; }
.calendar-filter-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem .65rem; margin-bottom: .5rem; }
.calendar-filter-summary :is(h2, h3) { margin: 0; }
.calendar-agenda p { color: var(--muted); line-height: 1.4; }
.calendar-events { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.calendar-event { display: grid; gap: .15rem; min-width: 0; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .6rem; background: #fbfcff; line-height: 1.35; overflow-wrap: anywhere; }
.calendar-event-meta { display: block; color: var(--muted); font-size: .875rem; font-weight: 650; }
.calendar-event a { color: var(--blue-dark); font-weight: 650; }
.calendar-event small { color: var(--muted); font-size: .875rem; }

.work-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(8rem, 100%), 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.work-metrics div { display: grid; align-content: start; gap: .28rem; padding: .75rem; border-right: 1px solid var(--line); }
.work-metrics div:last-child { border-right: 0; }
.work-metrics span { font-size: .875rem; color: var(--muted); }
.work-metrics strong { font-size: clamp(1rem, 3.7vw, 1.45rem); letter-spacing: -.03em; overflow-wrap: anywhere; }

.rules-toolbar { margin-bottom: .75rem; }
.rules-layout { display: grid; align-items: start; gap: 1rem; }
.rule-list { display: grid; gap: .8rem; min-width: 0; }
.rule-card, .rule-preview { background: var(--paper); padding: .9rem; border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow-wrap: anywhere; }
.rule-card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem; }
.rule-status { border-radius: .4rem; padding: .22rem .43rem; background: #edf1f8; color: #42526c; font-size: .875rem; font-weight: 650; }
.rule-status[data-enabled="true"] { background: #e9f6ef; color: #285d43; }
.rule-details { margin: .7rem 0; display: grid; gap: .65rem; }
.rule-details dt { font-size: .875rem; color: #465774; font-weight: 650; }
.rule-details dd { margin: .12rem 0 0; line-height: 1.4; }
.rule-criteria summary { min-height: 2.75rem; align-content: center; cursor: pointer; color: var(--blue-dark); font-size: .9375rem; font-weight: 650; }
.rule-preview { display: grid; gap: .65rem; }
.rule-preview p { line-height: 1.4; color: var(--muted); }
.rule-preview .button { justify-self: start; }
.rule-preview output:empty { display: none; }
.rule-preview output { padding: .6rem; border-radius: .65rem; background: var(--blue-soft); color: var(--blue-dark); line-height: 1.4; }

dialog { width: min(calc(100% - 1.4rem), 35rem); max-height: calc(100dvh - 1.4rem); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); box-shadow: 0 20px 80px #18284440; }
dialog::backdrop { background: #17274482; }
.dialog-content { display: grid; gap: .75rem; padding: .9rem; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.dialog-head h2 { font-size: 1.35rem; letter-spacing: -.025em; }
.icon-button { border: 0; color: var(--muted); background: #edf1f8; border-radius: .65rem; width: 2.75rem; height: 2.75rem; font-size: 1.45rem; }
.dialog-content label, .rule-preview label { font-size: .9375rem; font-weight: 650; }
.dialog-content label input, .dialog-content label select, .dialog-content label textarea { margin-top: .3rem; }
input:not([type="checkbox"]), textarea, select { width: 100%; min-height: 2.75rem; color: var(--ink); padding: .55rem; border: 1px solid #c7d2e2; border-radius: .55rem; background-color: var(--paper); }
input[readonly] { background: #f5f7fb; }
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #63748b; }
select { appearance: none; padding-right: 2rem; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%233c5172' stroke-width='1.5'%3E%3Cpath d='m5 8 5 5 5-5'/%3E%3C/svg%3E") right .45rem center / 1.1rem no-repeat; }
.checkbox-label { display: flex; align-items: center; gap: .45rem; min-height: 2.75rem; }
.checkbox-label input { width: 1.2rem; height: 1.2rem; accent-color: var(--blue); }
.dialog-content small { display: block; margin-top: .2rem; color: var(--muted); font-size: .875rem; font-weight: 400; }
.field-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr)); gap: .6rem; }
.field-pair label { min-width: 0; }
.dialog-actions, .voice-tools { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.dialog-actions { justify-content: flex-end; margin-top: .1rem; }
.voice-tools p, .form-error { color: var(--muted); line-height: 1.4; font-size: .875rem; }
.form-error { color: #a62737; }
.form-error:empty { display: none; }
.notice { position: fixed; z-index: 10; bottom: calc(4.6rem + env(safe-area-inset-bottom)); right: 1rem; left: 1rem; padding: .65rem .85rem; color: #fff; background: #203051; border-radius: .65rem; opacity: 0; pointer-events: none; box-shadow: 0 .35rem 1.4rem #18284430; }
.notice.visible { opacity: 1; }

@media (max-width: 22rem) {
  .topbar { gap: .35rem; padding-inline: .65rem; }
  .topbar .brand { gap: .4rem; font-size: .9375rem; }
  .topbar .brand-icon { width: 1.95rem; height: 1.95rem; }
  .topbar .button { padding-inline: .5rem; }
  .calendar { margin-inline: -.25rem; padding-inline: .25rem; }
}

@media (min-width: 44rem) {
  .view { padding-inline: 2rem; }
  .topbar { padding-inline: 2rem; }
  .topbar-date { display: block; color: var(--muted); font-size: .9375rem; }
  .entry-summary { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, .65fr) auto; grid-template-areas: 'title next side chevron'; padding: .85rem 1rem; gap: .75rem; }
  .entry-chevron { align-self: center; }
  .case-table { display: table; table-layout: fixed; }
  .case-table thead { position: static; display: table-header-group; width: auto; height: auto; overflow: visible; clip-path: none; }
  .case-table tbody { display: table-row-group; }
  .case-table .case-row, .case-table .case-detail-row:not([hidden]) { display: table-row; }
  .case-table th, .case-table td { display: table-cell; padding: .75rem .85rem; vertical-align: top; text-align: left; }
  .case-table th { border-bottom: 1px solid var(--line); background: #f2f5fb; color: #435574; font-size: .875rem; }
  .case-table th:first-child { width: 33%; border-start-start-radius: calc(var(--radius) - 1px); }
  .case-table th:nth-child(2) { width: 31%; }
  .case-table th:last-child { border-start-end-radius: calc(var(--radius) - 1px); }
  .case-table .case-detail-row td { padding: 0; }
  .case-open { min-height: 2.25rem; align-items: flex-start; }
  .case-mobile-label { display: none; }
  .calendar { padding: .8rem; }
  .calendar-head { margin-bottom: .7rem; }
  .work-metrics div, .rule-card, .rule-preview { padding: 1rem; }
}

@media (min-width: 62rem) {
  .shell { display: grid; grid-template-columns: 14.5rem minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 2rem; padding: 1.4rem 1rem; background: var(--paper); border-right: 1px solid var(--line); }
  .sidebar > .brand { display: inline-flex; margin-left: .35rem; font-size: 1.13rem; }
  .sidebar-foot { display: flex; align-items: center; gap: .4rem; margin: auto 0 0 .35rem; color: var(--muted); font-size: .875rem; }
  .demo-dot { background: #6382d8; width: .45rem; height: .45rem; border-radius: 50%; }
  .navigation { position: static; display: grid; grid-template-columns: 1fr; gap: .32rem; padding: 0; border: 0; }
  .navigation a { flex-direction: row; justify-content: flex-start; padding: 0 .75rem; gap: .7rem; min-height: 2.85rem; font-size: .9375rem; }
  .nav-full { display: inline; }
  .nav-short, .mobile-brand { display: none; }
  .view { padding: 2.5rem 2.5rem 3rem; }
  .topbar { padding-inline: 2.5rem; min-height: 4.5rem; }
  .topbar .button { font-size: .9375rem; padding-inline: .9rem; }
  .brief { padding: .9rem 1rem; }
  .brief-icon { width: 2.75rem; }
  .group, .case-group { margin-top: 1.45rem; }
  .rules-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .notice { left: auto; bottom: 1.25rem; max-width: 28rem; }
}
