:root {
  color-scheme: light;
  --paper: #fff;
  --bg: #f3f6f9;
  --ink: #192b3a;
  --muted: #526a79;
  --border: #dce5eb;
  --accent: #00688a;
  --accent-hover: #005674;
  --accent-soft: #e8f4f8;
  --side: #122835;
  --error: #9e261e;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); min-width: 290px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
:where(button, input, select, summary, a):focus-visible { outline: 3px solid #148cad; outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.95rem, 3.5vw, 2.8rem); line-height: 1.12; letter-spacing: -.042em; }
h2 { font-size: 1.17rem; line-height: 1.25; letter-spacing: -.015em; }
label { display: grid; gap: .38rem; font-size: .89rem; font-weight: 650; color: var(--ink); }
input:not([type=checkbox]), select {
  min-width: 0; width: 100%; background: var(--paper); color: var(--ink); border: 1px solid #b9ccd7;
  border-radius: .62rem; min-height: 2.85rem; padding: .55rem .73rem;
}
input::placeholder { color: #647d8b; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--accent); }
.primary, .quiet, .text-button, .outline {
  border: 0; border-radius: .6rem; padding: .61rem .9rem; font-weight: 670; min-height: 2.55rem;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }
.primary span { margin-left: .32rem; }
.outline { border: 1px solid #b5cbd7; background: var(--paper); color: var(--accent); }
.quiet, .text-button { color: var(--accent); background: transparent; }
.quiet:hover, .outline:hover, .text-button:hover { background: var(--accent-soft); }
.hint { color: var(--muted); font-size: .88rem; font-weight: 400; }
.brand { display: flex; align-items: center; gap: .65rem; font-size: 1.24rem; font-weight: 760; letter-spacing: -.035em; color: white; }
.brand-icon {
  display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .67rem;
  background: #e3f6fc; color: #075975; font-weight: 850;
}
.brand-dark { color: var(--ink); }
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 1.2rem;
  background: radial-gradient(ellipse at 32% 5%, #e1f3f8 0%, #edf4f8 40%, #f6f8fa 100%);
}
.login-card {
  width: min(100%, 430px); padding: clamp(1.5rem, 5vw, 2.6rem); border: 1px solid var(--border);
  border-radius: 1.3rem; background: var(--paper); box-shadow: 0 15px 65px #1a38501a;
}
.login-card h1 { font-size: 2rem; margin: 1.8rem 0 1.25rem; }
.login-card form { display: grid; gap: 1rem; }
.login-card .hint { margin-top: 1.1rem; }
.workspace { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  min-height: 100vh; position: sticky; top: 0; align-self: start; padding: 1.7rem 1rem 1.2rem;
  background: var(--side); color: #c1d0d9; display: flex; flex-direction: column; gap: 2.35rem;
}
.sidebar .brand { margin-left: .5rem; }
.sidebar nav { display: grid; gap: .3rem; }
.nav-button {
  display: flex; align-items: center; width: 100%; gap: .62rem; min-height: 2.8rem; padding: .65rem .66rem;
  text-align: left; color: #d9e7ee; border: 1px solid transparent; background: transparent; border-radius: .64rem;
}
.nav-button span { flex: 0 0 1.25rem; color: #9fc2d0; text-align: center; font-size: 1.15rem; line-height: 1; }
.nav-button:is(:hover, [aria-current=page]) { background: #254653; color: white; }
.nav-button[aria-current=page] { border-color: #467586; }
.sidebar-bottom { margin-top: auto; padding: .8rem .55rem 0; border-top: 1px solid #38515e; }
.sidebar-hint { font-size: .8rem; color: #aac3ce; }
.user { display: flex; align-items: center; justify-content: space-between; gap: .55rem; padding-top: .5rem; }
.user span { overflow-wrap: anywhere; color: white; font-weight: 650; }
.user button { background: transparent; color: #d8edf7; border: 1px solid #547485; border-radius: .54rem; padding: .2rem .55rem; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  min-height: 4.2rem; padding: .75rem clamp(1rem, 3.5vw, 2.8rem); background: var(--paper);
  color: var(--muted); border-bottom: 1px solid var(--border); font-size: .88rem; font-weight: 650;
}
.preview-tag, .pill {
  display: inline-flex; align-items: center; border-radius: 999px; background: var(--accent-soft); color: #075975;
  padding: .22rem .58rem; font-size: .81rem; font-weight: 680;
}
.content { max-width: 1440px; margin: 0 auto; padding: 2rem clamp(1rem, 3.5vw, 2.8rem) 4rem; }
.screen-title { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .85rem; margin-bottom: 1.55rem; }
.screen-lead { margin: -.9rem 0 1.5rem; color: var(--muted); }
.composer { display: grid; gap: 1.15rem; grid-template-columns: minmax(0, 1.21fr) minmax(270px, .79fr); align-items: start; }
.card {
  background: var(--paper); border: 1px solid var(--border); border-radius: 1rem;
  padding: 1.3rem; box-shadow: 0 3px 13px #344c6209;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1.15rem; }
.fields-card .destination-hint { margin: .46rem 0 1.1rem; }
.two-fields { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(10rem, 1fr); gap: .75rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .78rem; align-items: center; margin-top: 1.25rem; }
.link-guidance { margin-top: 1.1rem; padding: .65rem .82rem; border-radius: .6rem; background: var(--accent-soft); color: #295465; font-size: .86rem; }
.sources-card .card-header { margin-bottom: .45rem; }
.source-groups details + details { border-top: 1px solid var(--border); }
.source-groups summary { cursor: pointer; padding: .72rem .05rem; font-size: .92rem; font-weight: 740; }
.source-groups summary .hint { margin-left: .4rem; }
.source-options { display: grid; gap: .4rem; padding: .12rem 0 .72rem .47rem; }
.source-option { display: flex; align-items: flex-start; gap: .57rem; font-weight: 500; cursor: pointer; }
.source-option input { margin-top: .13rem; flex-shrink: 0; }
.source-details { display: grid; gap: .55rem; margin: .18rem 0 .5rem 1.5rem; }
.source-details label { font-size: .83rem; }
.source-details input { min-height: 2.25rem; padding: .34rem .53rem; }
.source-toolbar { display: flex; gap: .3rem; margin: 0 0 .15rem -.3rem; }
.source-toolbar .quiet { padding: .25rem .4rem; min-height: 1.8rem; font-size: .8rem; }
.notice { border-radius: .58rem; padding: .7rem .85rem; background: var(--accent-soft); overflow-wrap: anywhere; }
.notice.error { background: #fff0ef; color: var(--error); }
#global-notice { margin-bottom: 1rem; }
.form-error { margin-top: 1rem; }
.result-section, .history-section { margin-top: 1.35rem; }
.result-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.result-head p { margin-top: .28rem; }
.actions { display: flex; flex-wrap: wrap; gap: .48rem; align-items: center; }
.actions a { text-decoration: none; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; margin: 1.1rem 0; }
.stat-grid > div { background: #eff5f8; border-radius: .67rem; padding: .63rem .85rem; }
.metric { display: block; font-size: 1.42rem; font-weight: 760; font-variant-numeric: tabular-nums; }
.metric-label { display: block; font-size: .82rem; color: var(--muted); }
.period-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin: .75rem 0; }
.period-form input { min-height: 2.55rem; }
.period-form label { max-width: 13rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .88rem; }
th { color: var(--muted); font-size: .8rem; font-weight: 680; }
td, th { border-bottom: 1px solid var(--border); padding: .67rem .6rem; vertical-align: middle; }
td:first-child, th:first-child { padding-left: 0; }
tr:last-child td { border-bottom: 0; }
.cell-link { max-width: 24rem; }
.cell-link a { display: block; max-width: min(25vw, 17rem); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cell-link button { margin-left: -.4rem; font-size: .75rem; padding: .19rem .43rem; min-height: 1.65rem; }
.count-note { margin: .75rem 0 .2rem; }
.number { font-variant-numeric: tabular-nums; }
.rule-code { max-width: 19rem; overflow-wrap: anywhere; }
.rule-code code, code { font-size: .81em; }
.list-empty { color: var(--muted); padding: .7rem 0; }
dialog {
  width: min(100% - 1.4rem, 570px); max-height: min(88vh, 830px); padding: 1.35rem; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 1rem; box-shadow: 0 18px 70px #1129354d; color: var(--ink);
}
dialog::backdrop { background: #12283585; }
dialog form { display: grid; gap: .8rem; }
.dialog-header, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.dialog-actions { justify-content: flex-end; }
.dialog-header .quiet { font-size: 1.4rem; line-height: 1; padding: .2rem .65rem; }
.rule-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.rule-fields .wide { grid-column: 1/-1; }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: 209px minmax(0, 1fr); }
  .composer { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 690px) {
  .workspace { display: block; }
  .sidebar { min-height: auto; position: static; gap: .7rem; padding: .88rem 1rem .7rem; }
  .sidebar .brand { margin: 0; }
  .sidebar nav { display: flex; overflow: auto; padding: 0 2px .3rem; }
  .nav-button { width: auto; min-height: 2.35rem; flex: 0 0 auto; padding: .32rem .55rem; }
  .sidebar-bottom { padding: 0; border-top: 0; }
  .sidebar-hint { display: none; }
  .user { padding-top: 0; }
  .topbar { min-height: 2.7rem; padding-block: .4rem; }
  .content { padding-top: 1.4rem; }
  .card { padding: 1rem; }
  .two-fields { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .cell-link a { max-width: 7rem; }
}
