:root {
  --blue: #196396;
  --blue-dark: #10496f;
  --green: #2dbf7f;
  --ink: #1b1e24;
  --muted: #586372;
  --surface: #f4f6f8;
  --line: #d9dfe5;
  --pale: #edf3f7;
  --white: #fff;
  --radius: 6px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--blue); text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
button:focus:not(:focus-visible), #page-title:focus { outline: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 26px; font-weight: 650; line-height: 1.25; letter-spacing: -.02em; }
h2 { margin-bottom: 6px; font-size: 18px; font-weight: 650; line-height: 1.35; }
h3 { margin-bottom: 4px; font-size: 15px; font-weight: 650; line-height: 1.4; }
.muted { color: var(--muted); }
.eyebrow { display: none; }
.skip { position: fixed; z-index: 100; left: 16px; top: -80px; padding: 12px; background: white; border: 1px solid var(--line); }
.skip:focus { top: 12px; }

/* Navigation and workspace */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 212px; display: flex; flex-direction: column; padding: 24px 16px 16px; background: white; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; justify-content: flex-start; min-height: 56px; padding: 0 12px 16px; }
.brand img { display: block; width: 144px; height: 48px; object-fit: contain; }
.product-name { padding: 16px 12px 12px; border-top: 1px solid var(--line); margin-top: 8px; color: var(--muted); font-size: 14px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav button { min-height: 44px; padding: 10px 12px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); text-align: left; font-weight: 500; }
.sidebar nav button:hover { background: var(--surface); color: var(--ink); }
.sidebar nav button[aria-current] { color: var(--blue-dark); background: var(--pale); font-weight: 650; }
.sidebar-bottom { margin-top: auto; padding: 16px 0 0; border-top: 1px solid var(--line); }
.sidebar-bottom a { display: flex; align-items: center; min-height: 44px; padding: 10px 12px; font-size: 13px; text-decoration: none; }
.shell { margin-left: 212px; }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 28px; background: white; border-bottom: 1px solid var(--line); }
.topbar-leading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { font-weight: 600; color: var(--muted); }
#menu-toggle, .mobile-brand { display: none; }
#hub-auth-slot { min-width: 0; }
#hub-auth-slot .ha-user-badge { min-width: 0; }
#hub-auth-slot .ha-user-badge span { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hub-auth-slot .ha-logout-btn { min-height: 44px; min-width: 44px; border-radius: 4px; }
main { max-width: 1440px; min-height: calc(100vh - 122px); margin: 0 auto; padding: 28px 28px 48px; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.heading > div { min-width: 0; }
.heading p:last-child { margin: 0; color: var(--muted); }
.primary, .secondary, .quiet, .danger { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid transparent; border-radius: 4px; font-weight: 600; line-height: 1.4; text-decoration: none; }
.primary { background: var(--blue); color: white; }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.secondary { background: white; border-color: #b9c3cd; color: var(--ink); }
.secondary:hover:not(:disabled) { background: var(--surface); }
.quiet { background: transparent; color: var(--blue); padding-inline: 10px; }
.quiet:hover:not(:disabled) { background: var(--pale); }
.danger { background: #fff4f1; color: #922d1b; border-color: #e6c1b8; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; min-width: 0; }
.toolbar label, .list-filters label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
select, input, textarea { min-width: 0; min-height: 44px; max-width: 100%; padding: 10px 12px; border: 1px solid #b9c3cd; border-radius: 4px; background: white; color: var(--ink); }
select { min-width: 180px; }
textarea { min-height: 96px; resize: vertical; }
input[type='checkbox'] { width: 22px; height: 22px; min-height: 22px; padding: 0; accent-color: var(--blue); }
input[type='file'] { width: 100%; }
.checkbox-target { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.pill { display: inline-block; max-width: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 12px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.neutral { color: var(--muted); }
.pending, .warning-text { color: #805600; }
.good, .success-text { color: #19623e; }
.bad { color: #922d1b; }
.notice { margin: 0 0 20px; padding: 12px 14px; border: 1px solid #ccd9e4; border-radius: 4px; background: var(--pale); color: #294f69; font-size: 13px; }
.notice.error { background: #fff4f1; border-color: #e6c1b8; color: #922d1b; }
.notice p { margin: 0; }

/* Overview and company records */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.stat { padding: 14px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat > span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 24px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.columns { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin-bottom: 2px; font-size: 16px; }
.panel-header p { margin: 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 18px; }
.empty { padding: 28px 20px; text-align: left; }
.empty h2 { font-size: 16px; }
.empty p { max-width: 56ch; margin: 6px 0 16px; color: var(--muted); font-size: 14px; }
.empty p:last-child { margin-bottom: 0; }
.empty-symbol, .product-mark, .initial { display: none; }
.company-row, .schedule-row, .activity-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.company-row { flex-direction: column; align-items: stretch; gap: 4px; }
.company-row .identity { width: 100%; }
.company-row:last-child, .schedule-row:last-child, .activity-row:last-child { border-bottom: 0; }
.company-row p, .schedule-row p, .activity-row p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.company-row h3, .schedule-row h3 { font-size: 14px; }
.identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.company-heading { min-width: 0; }
.company-logo { display: block; flex: none; width: 100px; height: 40px; object-fit: contain; object-position: left center; }
.text-end { text-align: right; }
.date-block { display: grid; place-items: center; flex: none; width: 36px; min-height: 40px; font-size: 18px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.subnote { margin: 20px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.subnote span { display: none; }
.grid-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.company-card { padding: 20px; }
.company-card .company-logo { width: 150px; height: 55px; margin-bottom: 16px; }
.company-card h2 { font-size: 18px; margin-bottom: 8px; }
.company-card ul { margin: 16px 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.company-card > section { margin: 16px 0; font-size: 13px; }
.company-card > section p { margin-bottom: 6px; }
.company-card > button { margin-top: 8px; }
.history-details { width: 100%; margin-top: 4px; }
.history-details summary { min-height: 44px; display: list-item; padding: 12px 0; font-size: 12px; color: var(--muted); cursor: pointer; }
.history-details section { padding-bottom: 4px; }

/* Lists and forms */
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.section-title p { margin: 0; color: var(--muted); font-size: 13px; }
#content > section + section, #content > .section-title:not(:first-child) { margin-top: 28px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 14px; background: #f8f9fb; color: var(--muted); text-align: left; font-size: 12px; font-weight: 600; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
td strong { font-weight: 600; }
.note-identity { min-width: 150px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; }
.row-actions button { font-size: 13px; }
.amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.batch-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.batch-actions p { margin: 0; color: var(--muted); font-size: 13px; }
.list-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0 0 16px; }
.list-filters input, .list-filters select { min-width: 140px; max-width: 220px; }
.pagination { display: flex; justify-content: center; padding: 12px; }
fieldset { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 4px; min-width: 0; }
legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.batch-item { display: grid; gap: 12px; }
.batch-item legend { font-weight: 600; }
.batch-item p { margin-bottom: 4px; overflow-wrap: anywhere; }
.batch-result { margin: 0; font-size: 13px; }
.connection-card { padding: 20px; }
.connection-card p { color: var(--muted); font-size: 13px; }
.safe-note { margin: 20px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: #f8f9fb; font-size: 13px; overflow-wrap: anywhere; }
.safe-note p { margin: 0; }
.timeline { margin-top: 20px; }
.timeline ol { margin: 12px 0 0; padding: 0 0 0 16px; border-left: 1px solid var(--line); list-style: none; }
.timeline li { padding: 0 0 16px; }
.timeline small { display: block; color: var(--muted); font-size: 12px; }
.timeline p { margin: 4px 0; font-size: 13px; }
.version-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.version-row small, .version-row p { font-size: 12px; }
.version-row small { display: block; }
.version-row p { margin: 4px 0 0; }
.version-row .quiet { flex: none; }
footer { display: flex; justify-content: space-between; gap: 16px; max-width: 1440px; margin: auto; padding: 16px 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

/* Dialogs */
dialog { width: 640px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #b9c3cd; border-radius: 6px; color: var(--ink); box-shadow: none; }
dialog::backdrop { background: rgba(27, 30, 36, .45); }
dialog form { padding: 24px; }
dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
dialog header h2 { margin: 0; font-size: 20px; }
.close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--muted); font-size: 24px; line-height: 1; }
#editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
#editor-fields label { display: grid; gap: 6px; min-width: 0; color: #43515f; font-size: 13px; font-weight: 500; }
#editor-fields select, #editor-fields input { width: 100%; min-width: 0; }
#editor-fields small { color: var(--muted); font-weight: 400; }
#editor-fields .check-label { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; cursor: pointer; }
#editor-fields .check-label input { flex: none; width: 22px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.detail-grid > div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-grid small { display: block; color: var(--muted); font-size: 12px; }
.detail-grid strong { display: block; margin-top: 4px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
#editor-error { margin: 16px 0 0; color: #922d1b; font-size: 13px; }
.snapshot-hash { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.screen-only { display: contents; }

@media (max-width: 1150px) {
  .columns { grid-template-columns: minmax(0, 1fr); }
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .sidebar { display: none; position: fixed; inset: 64px 0 auto; width: 100%; max-height: calc(100dvh - 64px); overflow-y: auto; padding: 12px 16px; border-right: 0; border-bottom: 1px solid #b9c3cd; }
  .sidebar.is-open { display: flex; }
  .sidebar .brand, .product-name { display: none; }
  .sidebar nav { display: grid; grid-template-columns: 1fr; gap: 4px; }
  .sidebar nav button { min-height: 48px; padding: 12px; font-size: 16px; }
  .sidebar-bottom { margin-top: 12px; padding-top: 8px; }
  .sidebar-bottom a { font-size: 14px; }
  .shell { margin-left: 0; }
  .topbar { position: sticky; top: 0; z-index: 40; height: 64px; min-height: 64px; padding: 8px 16px; gap: 8px; }
  .topbar-leading { gap: 12px; }
  #menu-toggle { display: inline-flex; min-width: 64px; padding-inline: 10px; }
  .mobile-brand { display: flex; align-items: center; min-height: 44px; }
  .mobile-brand img { display: block; width: 104px; height: 36px; object-fit: contain; }
  .topbar-title { display: none; }
  #hub-auth-slot { margin-left: auto; }
  #hub-auth-slot .ha-user-badge { display: none; }
  #hub-auth-slot .ha-logout-btn span { display: inline; }
  main { min-height: calc(100dvh - 120px); padding: 24px 16px 32px; }
  .heading { align-items: flex-start; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
  .heading > div { flex: 1 1 200px; }
  h1 { font-size: 24px; }
  .heading .muted { font-size: 14px; }
  .heading > .primary { flex: 1 0 100%; }
  .toolbar { gap: 12px; margin-bottom: 20px; padding-bottom: 16px; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; gap: 12px; }
  .toolbar label, .list-filters label { font-size: 13px; }
  .toolbar select, .toolbar input { width: 100%; min-width: 0; }
  .toolbar-right { justify-content: space-between; width: 100%; }
  input, select, textarea { font-size: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 20px; }
  .stat { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:nth-last-child(-n+2) { border-bottom: 0; }
  .stat strong { font-size: 24px; }
  .stat small { font-size: 11px; }
  .grid-cards { grid-template-columns: minmax(0, 1fr); }
  .panel-header { flex-wrap: wrap; gap: 8px; padding: 14px 16px; }
  .panel-header .quiet { margin-left: -10px; }
  .company-row, .schedule-row, .activity-row { padding: 14px 16px; gap: 12px; }
  .schedule-row { align-items: flex-start; }
  .schedule-row .identity { align-items: flex-start; gap: 8px; }
  .schedule-row .text-end { flex: 0 0 100px; }
  .schedule-row p, .company-row p { font-size: 12px; }
  .date-block { width: 28px; }
  .company-logo { width: 96px; }
  .company-card { padding: 18px; }
  .section-title { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .section-title h2 { font-size: 18px; }
  .section-title p { font-size: 13px; }
  .list-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .list-filters label { grid-column: 1 / -1; min-width: 0; }
  .list-filters input, .list-filters select { width: 100%; min-width: 0; max-width: 100%; }
  .batch-actions { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  .batch-actions .primary { width: 100%; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  tr:last-child { border-bottom: 0; }
  td { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 6px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  td::before { content: attr(data-label); flex: 0 0 34%; color: var(--muted); text-align: left; font-size: 12px; }
  td > * { min-width: 0; max-width: 66%; }
  td:has(input[type='checkbox']) { min-height: 44px; align-items: center; }
  td .row-actions { max-width: 100%; margin-left: auto; }
  td .note-identity { min-width: 0; }
  .row-actions { gap: 4px; }
  .empty { padding: 24px 16px; }
  .notice { padding: 12px; font-size: 13px; }
  .detail-grid, #editor-fields { grid-template-columns: minmax(0, 1fr); }
  .wide { grid-column: auto; }
  dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
  dialog form { padding: 16px; }
  dialog header { gap: 12px; margin-bottom: 16px; }
  dialog header h2 { font-size: 19px; }
  #editor-fields label { font-size: 14px; }
  .dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .version-row { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .connection-card p { min-height: 0; }
  footer { flex-wrap: wrap; padding: 16px; gap: 4px 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, a { transition: background-color .12s ease, color .12s ease; }
}

.list-filter-panel { margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.list-filter-panel > summary { min-height: 44px; padding: 12px 0; color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.list-filter-panel[open] .list-filters { margin-top: 12px; margin-bottom: 0; }
