:root {
  color-scheme: light;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #f2f5f7;
  --panel: #fcfdfe;
  --edge: #cbd5df;
  --text: #223247;
  --muted: #51647a;
  --cyan: #126478;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at top right, #e1edf2, var(--bg) 45rem); color: var(--text); min-height: 100vh; }
a { color: var(--cyan); text-underline-offset: .22em; }
a:hover { color: #0d4b5a; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.frame { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
aside { border-right: 1px solid var(--edge); background: #e8eff3; padding: 1.6rem 1.25rem; }
.brand { display: flex; align-items: center; gap: .9rem; font-weight: 750; letter-spacing: .1em; }
.brand small { display: block; letter-spacing: normal; color: var(--muted); font-weight: 400; }
.core { display: block; width: 2.6rem; height: 2.6rem; flex: 0 0 auto; border: 1px solid var(--cyan); border-radius: 50%; background: radial-gradient(circle, #8adce8 6%, #71c2d0 10%, #e1f1f5 43%, #46a3b4 46%, #ebf6f7 50%, #f8fbfc 72%); box-shadow: 0 0 18px #12647825; }
nav { display: grid; gap: .35rem; margin: 2rem 0; }
nav a, .chip { display: inline-block; border-radius: .55rem; padding: .55rem .75rem; color: var(--muted); text-decoration: none; }
.selected { background: #dbebef; color: var(--cyan); box-shadow: inset 0 0 0 1px #9abfc9; }
main { width: 100%; max-width: 90rem; padding: 2rem clamp(1rem, 4vw, 4rem); min-width: 0; }
header { margin-bottom: 1.6rem; padding-bottom: .9rem; border-bottom: 1px solid var(--edge); }
h1, h2 { margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.7rem, 4vw, 2.65rem); font-weight: 690; }
h2 { font-size: 1.16rem; margin: 1.8rem 0 .8rem; }
p { margin: 0; }
.auth { width: min(100%, 30rem); margin: 9vh auto; padding: 1.5rem; }
.auth .core { margin-bottom: 1rem; width: 4rem; height: 4rem; }
.auth h1 { margin-bottom: 1.4rem; letter-spacing: .1em; }
.surface, .metric, .table { background: var(--panel); border: 1px solid var(--edge); border-radius: .85rem; }
.surface { padding: 1.1rem; margin: 1rem 0; }
.stack { display: grid; gap: .9rem; }
.stack h2, .toolbar h2 { margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .8rem; margin-bottom: 1rem; }
.metric { display: grid; gap: .45rem; padding: 1rem; border-top-color: #75acb8; }
.metric span, .muted, dt { color: var(--muted); }
.metric strong { color: var(--cyan); font-size: 1.8rem; }
.toolbar, .tabs, .search { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.toolbar { justify-content: space-between; margin: 1rem 0; }
.search { margin-bottom: 1rem; }
.search input { flex: 1; min-width: 10rem; }
.inline { display: inline; }
button, .button { font: inherit; display: inline-flex; align-items: center; color: var(--text); border: 1px solid var(--edge); background: #eaf1f5; padding: .53rem .85rem; border-radius: .55rem; cursor: pointer; text-decoration: none; min-height: 44px; }
button:hover, .button:hover { border-color: var(--cyan); color: var(--text); }
.primary { color: #ffffff; background: var(--cyan); border-color: var(--cyan); font-weight: 650; }
.primary:hover { background: #0d5263; color: #ffffff; }
label { display: grid; gap: .35rem; min-width: 0; }
input, select, textarea { font: inherit; color: var(--text); background: #fcfdfe; border: 1px solid #899bae; border-radius: .45rem; padding: .58rem .7rem; width: 100%; min-width: 0; min-height: 44px; }
textarea { resize: vertical; }
.editor, .detail { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.editor .toolbar { grid-column: 1 / -1; justify-content: flex-start; }
dd { margin: .2rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.table { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .7rem .85rem; border-bottom: 1px solid var(--edge); overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 600; background: #eaf0f5; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f0f6f8; }
.badge { display: inline-block; border: 1px solid #9abfc9; background: #e4f0f3; border-radius: 1rem; color: var(--cyan); padding: .15rem .55rem; }
.warn { color: #924318; }
.notice { border-left: 3px solid var(--cyan); padding: .7rem .9rem; background: #e7f2f5; margin: 1rem 0; }
@media (max-width: 900px) {
  .frame { grid-template-columns: 1fr; }
  aside { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; border-right: 0; border-bottom: 1px solid var(--edge); padding: .8rem 1rem; }
  nav { order: 2; width: 100%; display: flex; flex-wrap: wrap; margin: 0; }
  nav a { min-height: 44px; }
}
@media (max-width: 620px) {
  main { padding: 1.15rem .85rem; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .editor, .detail { grid-template-columns: minmax(0,1fr); }
  table { min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr, td { display: block; }
  tbody tr { padding: .4rem .65rem; border-bottom: 1px solid var(--edge); }
  tbody tr:last-child { border: 0; }
  td { border: 0; display: grid; grid-template-columns: minmax(6.4rem,36%) minmax(0,1fr); gap: .5rem; padding: .35rem .2rem; }
  td::before { content: attr(data-label); color: var(--muted); }
  .table { overflow: visible; }
}

.status-active { --status-bg: #e8f4ec; --status-text: #236241; --status-edge: #a6cdb4; }
.status-paused { --status-bg: #fbf2d9; --status-text: #745211; --status-edge: #dbc27d; }
.status-archive { --status-bg: #f8e9e8; --status-text: #8d3535; --status-edge: #dcb0ae; }
.status-mine { --status-bg: #e9f0fb; --status-text: #244c83; --status-edge: #adc3e4; }
.project-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.project-metrics .metric, .badge[class*="status-"], .chip[class*="status-"] {
  background: var(--status-bg);
  border-color: var(--status-edge);
  color: var(--status-text);
  text-decoration: none;
}
.project-metrics .metric span, .project-metrics .metric strong { color: inherit; }
.project-metrics .metric:hover, .chip[class*="status-"]:hover { box-shadow: inset 0 0 0 1px var(--status-text); }
.chip[class*="status-"].selected { box-shadow: inset 0 0 0 2px var(--status-text); }
@media (max-width: 620px) {
  .project-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
  .project-metrics .metric { padding: .55rem; font-size: .82rem; overflow-wrap: anywhere; }
}

.project-own-row { background: #e9f0fb; }
.project-own-row:hover { background: #dbe8fa; }
.project-own-row td:first-child a { color: #244c83; }

.work-count { color: var(--text); text-decoration: none; }
.work-matrix { overflow-x: auto; border: 1px solid var(--edge); border-radius: .85rem; background: var(--panel); }
.work-matrix table { min-width: 66rem; text-align: center; border-collapse: separate; border-spacing: 0; }
.work-matrix :is(th, td) {
  padding: .25rem .45rem; border-right: 1px solid var(--edge); overflow-wrap: normal;
}
.work-matrix :is(th, td):last-child { border-right: 0; }
.work-matrix th:first-child { position: sticky; left: 0; z-index: 1; min-width: 8rem; text-align: left; }
.work-matrix tbody th { background: var(--panel); }
.work-matrix tbody tr:last-child th { border-bottom: 0; }
.work-matrix .work-own-row :is(th, td) { background: #e9f0fb; }
.work-matrix .work-own-row:hover :is(th, td) { background: #dbe8fa; }
.work-matrix .work-own-row th a { color: #244c83; }
.work-payment-day { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; line-height: 1.2; }
.work-form { display: inline-flex; margin: 0; }
.work-switch { background: transparent; border-color: transparent; justify-content: center; min-width: 58px; padding: 0 .3rem; }
.work-matrix .work-switch { min-height: 34px; }
.work-indicator { position: relative; display: block; width: 42px; height: 22px; border-radius: 1rem; background: #aa3840; }
.work-indicator::after { position: absolute; content: ""; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; }
.work-switch[aria-checked="true"] .work-indicator { background: #28714a; }
.work-switch[aria-checked="true"] .work-indicator::after { left: 23px; }
.work-switch[aria-busy="true"] { opacity: .6; }
.balance-form { display: flex; gap: .25rem; align-items: center; justify-content: center; }
.balance-form input { width: 5.4rem; min-height: 32px; text-align: center; padding: .2rem; }
.balance-form button { min-height: 32px; padding: .2rem .35rem; font-size: .78rem; }
@media (max-width: 620px) {
  .work-matrix table { display: table; }
  .work-matrix thead { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .work-matrix tr { display: table-row; padding: 0; }
  .work-matrix :is(th, td) { display: table-cell; border-bottom: 1px solid var(--edge); }
  .work-matrix td::before { content: none; }
  .work-matrix th:first-child { min-width: 7rem; }
  .work-matrix .work-switch, .balance-form :is(input, button) { min-height: 38px; }
}

.status-clients { --status-bg: #edf0f7; --status-text: #37496b; --status-edge: #bcc8db; }
.overview-metrics .metric[class*="status-"] {
  background: var(--status-bg); border-color: var(--status-edge); color: var(--status-text); text-decoration: none;
}
.overview-metrics .metric[class*="status-"] :is(span, strong) { color: inherit; }
.overview-metrics a:hover { box-shadow: inset 0 0 0 1px currentColor; }
.project-info-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .75rem; }
.project-info { padding: .85rem; background: var(--panel); border: 1px solid var(--edge); border-radius: .85rem; min-width: 0; }
.project-info h2 { margin: 0 0 .55rem; }
.project-info dl, .project-info dd { margin: 0; }
.project-info dl > div { padding: .45rem 0; }
.project-info dt { display: flex; align-items: center; gap: .45rem; font-size: .85rem; }
.project-info dt span, .service-icon {
  display: inline-grid; place-items: center; width: 1.65rem; height: 1.65rem;
  border-radius: .45rem; background: #e3edf4; color: #2d5271; font-weight: 700;
}
.project-info.identity { background: #edf6ee; border-color: #bfd8c4; }
.project-info.identity dt span { background: #d6eadb; color: #246043; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(9rem, 100%),1fr)); gap: .55rem; }
.service-tile { display: grid; width: 100%; height: 100%; gap: .22rem; text-align: left; overflow-wrap: anywhere; }
.service-tile :is(span:not(.service-icon),small) { font-size: .82rem; }
.service-tile.is-enabled { background: #e8f4ec; border-color: #a6cdb4; color: #236241; }
.service-tile.is-disabled { background: #f8e9e8; border-color: #dcb0ae; color: #8d3535; }
.service-tile.is-enabled .service-icon { background: #d3e9d9; color: #236241; }
.service-tile.is-disabled .service-icon { background: #efd3d3; color: #8d3535; }
.service-tile:hover { box-shadow: inset 0 0 0 1px currentColor; }
.project-note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.urgent-form { display: flex; align-items: end; flex-wrap: wrap; gap: .6rem; }
.urgent-form label { flex: 1 1 15rem; }
@media (max-width: 620px) {
  .project-info-grid { grid-template-columns: 1fr; }
}

.calendar-filter { display: flex; align-items: end; flex-wrap: wrap; gap: .6rem; margin: .75rem 0 1rem; }
.calendar-filter select { min-width: 6.5rem; }
.bill-paid { background: #e8f4ec; }
.bill-overdue { background: #f8e9e8; }
.bill-upcoming { background: #fbf2d9; }
.bill-paid:hover { background: #dceee3; }
.bill-overdue:hover { background: #f4dddd; }
.bill-upcoming:hover { background: #f5e9c4; }
.payment-toggle { display: inline-flex; align-items: center; gap: .15rem; white-space: nowrap; }
.bill-upcoming .work-indicator { background: #9b731b; }
.finance-chart { border: 1px solid var(--edge); border-radius: .85rem; overflow: hidden; }
.finance-chart meter { width: min(12rem, 55%); vertical-align: middle; }
.finance-in { accent-color: #28714a; }
.finance-out { accent-color: #aa3840; }
@media (max-width: 620px) {
  .finance-chart thead { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .finance-chart tr { display: table-row; }
  .finance-chart :is(th, td) { display: table-cell; padding: .45rem; }
  .finance-chart td::before { content: none; }
  .finance-chart meter { display: block; width: 100%; }
}
