:root {
  --brand: #0084ff;
  --brand-dark: #0067c9;
  --brand-deep: #004f9e;
  --brand-soft: #eaf5ff;
  --brand-pale: #f4faff;
  --ink: #17202e;
  --text: #3d4858;
  --muted: #626f82;
  --faint: #6b7789;
  --border: #e7ebf1;
  --border-strong: #d7dde7;
  --canvas: #f6f8fb;
  --surface: #fff;
  --success: #11875d;
  --success-soft: #e8f8f1;
  --warning: #b86c09;
  --warning-soft: #fff5df;
  --danger: #d63b45;
  --danger-soft: #fff0f1;
  --purple: #7956cf;
  --purple-soft: #f2efff;
  --shadow-xs: 0 1px 2px rgba(19, 35, 55, .05);
  --shadow-sm: 0 6px 18px rgba(29, 48, 75, .07);
  --shadow-md: 0 18px 45px rgba(29, 48, 75, .12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-width: 254px;
  --topbar-height: 76px;
  font-family: "Source Sans Pro", "Source Sans 3", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--brand-dark); text-decoration: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(0, 132, 255, .24);
  outline-offset: 2px;
}

svg.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .15em;
}

.eyebrow-light { color: rgba(255,255,255,.72); }

.login-view {
  display: grid;
  grid-template-columns: minmax(390px, 44%) 1fr;
  min-height: 100vh;
  background: var(--surface);
}

.login-brand-panel {
  position: relative;
  display: flex;
  overflow: hidden;
  align-items: center;
  padding: clamp(44px, 7vw, 104px);
  color: white;
  background:
    radial-gradient(circle at 12% 15%, rgba(100, 203, 255, .34), transparent 26%),
    linear-gradient(145deg, #0056ad 0%, #0084ff 52%, #00a8ff 100%);
}

.login-brand-panel::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: .16;
  background-image: linear-gradient(rgba(255,255,255,.14) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.14) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom right, #000, transparent 72%);
}

.login-brand-content { position: relative; z-index: 2; max-width: 540px; }
.login-logo { width: 210px; height: auto; margin-bottom: clamp(64px, 9vh, 116px); object-fit: contain; }
.login-brand-content h1 { margin: 0 0 22px; max-width: 520px; color: #fff; font-size: clamp(36px, 4.1vw, 62px); line-height: 1.03; letter-spacing: -.045em; font-weight: 680; }
.login-brand-content > p:not(.eyebrow) { max-width: 480px; margin: 0; color: rgba(255,255,255,.78); font-size: 18px; line-height: 1.55; }
.login-feature-list { display: flex; flex-wrap: wrap; gap: 14px 26px; margin-top: 42px; color: rgba(255,255,255,.9); font-size: 14px; font-weight: 600; }
.login-feature-list span { display: inline-flex; gap: 8px; align-items: center; }
.login-feature-list svg { width: 17px; height: 17px; padding: 3px; border-radius: 50%; color: #0062b9; background: rgba(255,255,255,.86); stroke-width: 3; }
.login-orbit { position: absolute; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; }
.login-orbit-one { right: -150px; bottom: -190px; width: 520px; height: 520px; }
.login-orbit-two { right: 20px; bottom: -90px; width: 300px; height: 300px; }

.login-form-panel { display: flex; align-items: center; justify-content: center; padding: 48px 7vw; }
.login-card { width: min(100%, 420px); }
.login-logo-mobile { display: none; width: 190px; margin-bottom: 42px; }
.login-card h2 { margin: 0; color: var(--ink); font-size: 32px; line-height: 1.2; letter-spacing: -.025em; }
.login-copy { margin: 9px 0 34px; color: var(--muted); font-size: 16px; }
.login-security { display: flex; justify-content: center; gap: 8px; align-items: center; margin: 24px 0 0; color: var(--muted); font-size: 12px; }
.login-security svg { width: 16px; color: var(--success); }

.field { display: grid; gap: 8px; margin-bottom: 18px; color: var(--ink); font-size: 13px; font-weight: 650; }
.field > span:first-child { display: flex; justify-content: space-between; }
.field small.hint { color: var(--muted); font-weight: 400; }
.input-shell { display: flex; align-items: center; min-height: 50px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .2s, box-shadow .2s; }
.input-shell:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,132,255,.1); }
.input-shell > svg { width: 18px; margin-left: 15px; color: var(--faint); }
.input-shell input, .input-shell select, .input-shell textarea { width: 100%; min-width: 0; border: 0; outline: 0; padding: 13px 15px; color: var(--ink); background: transparent; font-weight: 450; }
.input-shell select { appearance: none; cursor: pointer; }
.input-shell textarea { min-height: 92px; resize: vertical; }
.input-shell.has-error { border-color: var(--danger); }
.field-error { min-height: 0; color: var(--danger); font-size: 12px; font-weight: 500; }
.field-error:empty { display: none; }
.lookup-feedback { display: flex; min-height: 0; align-items: center; gap: 7px; margin: -9px 0 14px; color: var(--muted); font-size: 12px; }
.lookup-feedback:empty { display: none; }
.lookup-feedback.success { color: #176b45; }
.lookup-feedback.warning { color: #8a5900; }
.lookup-feedback.error { color: var(--danger); }
.lookup-feedback .mini-spinner { border-color: #c5d3e3; border-top-color: var(--brand); }

.password-toggle { margin-right: 7px; }
.demo-credentials { margin-top: 16px; padding: 12px 14px; border: 1px solid #cce5ff; border-radius: var(--radius-sm); color: #155c91; background: var(--brand-pale); font-size: 13px; }
.demo-credentials strong { color: var(--brand-deep); }

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform .15s, background .2s, border-color .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { color: #fff; background: var(--brand-dark); box-shadow: 0 6px 14px rgba(0,103,201,.18); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-secondary { color: var(--ink); border-color: var(--border-strong); background: #fff; box-shadow: var(--shadow-xs); }
.btn-secondary:hover { border-color: #b9c5d5; background: #fafcff; }
.btn-soft { color: var(--brand-deep); background: var(--brand-soft); }
.btn-soft:hover { background: #dcefff; }
.btn-danger { color: #fff; background: var(--danger); }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-ghost:hover { color: var(--ink); background: var(--canvas); }
.btn-block { width: 100%; min-height: 50px; }
.btn-sm { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.mini-spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.45); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-secondary .mini-spinner { border-color: var(--border-strong); border-top-color: currentColor; }

.icon-btn {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--ink); background: var(--canvas); }
.icon-btn svg { width: 19px; height: 19px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.sidebar-head { display: flex; height: var(--topbar-height); flex: 0 0 var(--topbar-height); align-items: center; justify-content: space-between; padding: 0 25px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 158px; height: auto; }
.sidebar-close { display: none; }
.main-nav { overflow-y: auto; flex: 1; padding: 22px 14px; scrollbar-width: thin; }
.nav-label { margin: 20px 12px 7px; color: #667386; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.nav-label:first-child { margin-top: 0; }
.main-nav a { position: relative; display: flex; min-height: 43px; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: #5c6778; font-size: 13px; font-weight: 620; transition: color .2s, background .2s; }
.main-nav a:hover { color: var(--ink); background: var(--canvas); }
.main-nav a.active { color: var(--brand-dark); background: var(--brand-soft); }
.main-nav a.active::before { position: absolute; left: -14px; width: 3px; height: 23px; border-radius: 0 3px 3px 0; content: ""; background: var(--brand); }
.main-nav a svg { width: 19px; height: 19px; }
.nav-badge { display: inline-flex; min-width: 20px; height: 20px; margin-left: auto; align-items: center; justify-content: center; padding: 0 6px; border-radius: 10px; color: #fff; background: var(--danger); font-size: 10px; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.environment-card { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--canvas); }
.environment-card strong, .environment-card small { display: block; }
.environment-card strong { color: var(--ink); font-size: 11px; }
.environment-card small { margin-top: 1px; color: var(--muted); font-size: 10px; }
.environment-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); }
.environment-card.ok .environment-dot { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.environment-card.danger .environment-dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.sidebar-user { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 7px; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { color: var(--ink); font-size: 12px; }
.sidebar-user small { margin-top: 1px; color: var(--muted); font-size: 10px; }
.avatar { display: inline-flex; width: 37px; height: 37px; flex: 0 0 37px; align-items: center; justify-content: center; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--brand-dark), #12a7ff); font-size: 11px; font-weight: 750; letter-spacing: .02em; }
.avatar-small { width: 34px; height: 34px; flex-basis: 34px; }

.app-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; height: var(--topbar-height); align-items: center; gap: 22px; padding: 0 clamp(22px, 3vw, 42px); border-bottom: 1px solid var(--border); background: rgba(255,255,255,.95); backdrop-filter: blur(14px); }
.sidebar-open { display: none; }
.topbar-title { min-width: 155px; margin-right: auto; }
.topbar-title p { margin: 0 0 2px; color: var(--brand-dark); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.topbar-title h1 { margin: 0; color: var(--ink); font-size: 20px; line-height: 1.15; letter-spacing: -.015em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.global-search { display: flex; width: min(310px, 27vw); height: 40px; align-items: center; gap: 9px; padding: 0 10px 0 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--canvas); }
.global-search svg { width: 17px; color: var(--muted); }
.global-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.global-search kbd { padding: 2px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: #fff; font: 10px inherit; white-space: nowrap; }
.notification-button { position: relative; border: 1px solid var(--border); background: #fff; }
.notification-dot { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; border: 1px solid #fff; border-radius: 50%; background: var(--danger); }
.topbar-user { display: flex; align-items: center; gap: 9px; margin-left: 3px; padding: 3px 4px 3px 3px; border: 0; border-radius: 9px; cursor: default; background: transparent; text-align: left; }
.topbar-user strong, .topbar-user small { display: block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user strong { color: var(--ink); font-size: 11px; }
.topbar-user small { color: var(--muted); font-size: 9px; }
.topbar-user > svg { width: 14px; color: var(--muted); }

.main-content { min-height: calc(100vh - var(--topbar-height)); padding: 30px clamp(22px, 3vw, 42px) 54px; }
.page-container { width: 100%; max-width: 1500px; margin: 0 auto; animation: page-in .25s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.page-loader { display: grid; min-height: 55vh; place-items: center; align-content: center; gap: 14px; color: var(--muted); }
.page-loader span { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.page-loader p { margin: 0; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h2 { margin: 0; color: var(--ink); font-size: 24px; letter-spacing: -.025em; }
.page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.status-banner { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; padding: 12px 16px; border: 1px solid #cce5ff; border-radius: var(--radius); color: #175c91; background: var(--brand-pale); font-size: 13px; }
.status-banner svg { width: 18px; flex: 0 0 auto; color: var(--brand-dark); }
.status-banner strong { color: #104d7c; }
.status-banner .banner-action { margin-left: auto; color: var(--brand-deep); font-weight: 700; white-space: nowrap; }
.status-banner.warning { border-color: #f0ddb3; color: #7f560f; background: var(--warning-soft); }
.status-banner.warning svg { color: var(--warning); }
.status-banner.danger { border-color: #facdd1; color: #92313a; background: var(--danger-soft); }
.text-danger { color: #a32632 !important; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card { position: relative; overflow: hidden; min-height: 140px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-xs); }
.stat-card::after { position: absolute; right: -18px; bottom: -25px; width: 85px; height: 85px; border-radius: 50%; content: ""; background: var(--brand-soft); opacity: .55; }
.stat-card.success::after { background: var(--success-soft); }
.stat-card.warning::after { background: var(--warning-soft); }
.stat-card.danger::after { background: var(--danger-soft); }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.stat-icon { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 9px; color: var(--brand-dark); background: var(--brand-soft); }
.stat-icon svg { width: 17px; height: 17px; }
.success .stat-icon { color: var(--success); background: var(--success-soft); }
.warning .stat-icon { color: var(--warning); background: var(--warning-soft); }
.danger .stat-icon { color: var(--danger); background: var(--danger-soft); }
.stat-value { position: relative; z-index: 1; margin: 19px 0 6px; color: var(--ink); font-size: 25px; font-weight: 720; letter-spacing: -.025em; }
.stat-foot { position: relative; z-index: 1; display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 10px; }
.trend { display: inline-flex; gap: 2px; align-items: center; color: var(--success); font-weight: 700; }
.trend.down { color: var(--danger); }
.trend svg { width: 13px; height: 13px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .85fr); gap: 18px; margin-bottom: 18px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-xs); }
.card-head { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 19px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; color: var(--ink); font-size: 14px; letter-spacing: -.01em; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.card-body { padding: 20px; }
.card-head-actions { display: flex; align-items: center; gap: 8px; }
.text-link { display: inline-flex; align-items: center; gap: 5px; border: 0; cursor: pointer; color: var(--brand-dark); background: transparent; font-size: 11px; font-weight: 700; }
.text-link svg { width: 14px; }

.chart-legend { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; color: var(--muted); font-size: 10px; }
.chart-legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.legend-dot.payable { background: #afc3d8; }
.cash-chart { display: flex; height: 210px; align-items: end; justify-content: space-around; gap: 12px; padding-top: 10px; border-bottom: 1px solid var(--border); background: repeating-linear-gradient(to bottom, transparent 0, transparent 51px, #f1f3f6 52px); }
.chart-column { display: flex; min-width: 34px; height: 100%; flex: 1; flex-direction: column; justify-content: end; align-items: center; gap: 9px; }
.chart-bars { display: flex; width: min(70%, 42px); height: calc(100% - 24px); align-items: end; justify-content: center; gap: 3px; }
.chart-bar { width: 46%; min-height: 3px; border-radius: 4px 4px 1px 1px; background: var(--brand); transition: height .35s ease; }
.chart-bar.payable { background: #afc3d8; }
.chart-column > span { color: var(--muted); font-size: 10px; }

.integration-list { display: grid; }
.integration-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); }
.integration-row:first-child { padding-top: 0; }
.integration-row:last-child { padding-bottom: 0; border-bottom: 0; }
.integration-logo { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 9px; color: var(--brand-dark); background: var(--brand-soft); font-size: 12px; font-weight: 800; }
.integration-logo.gov { color: var(--success); background: var(--success-soft); }
.integration-row strong, .integration-row small { display: block; }
.integration-row strong { color: var(--ink); font-size: 12px; }
.integration-row small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.health-pill { display: inline-flex; gap: 5px; align-items: center; padding: 4px 7px; border-radius: 10px; color: var(--success); background: var(--success-soft); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.health-pill::before { width: 5px; height: 5px; border-radius: 50%; content: ""; background: currentColor; }
.health-pill.mock { color: var(--warning); background: var(--warning-soft); }
.health-pill.off { color: var(--danger); background: var(--danger-soft); }

.list-card { overflow: hidden; }
.table-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar-search { display: flex; width: min(340px, 100%); min-height: 39px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; }
.toolbar-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,132,255,.08); }
.toolbar-search svg { width: 16px; color: var(--muted); }
.toolbar-search input { width: 100%; border: 0; outline: 0; color: var(--ink); font-size: 12px; }
.filter-select { min-height: 39px; padding: 0 32px 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; outline: 0; color: var(--text); background: #fff; font-size: 11px; font-weight: 600; }
.filter-select:focus { border-color: var(--brand); }
.toolbar-spacer { flex: 1; }
.result-count { color: var(--muted); font-size: 11px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { padding: 11px 16px; border-bottom: 1px solid var(--border); color: #647185; background: #fbfcfd; font-size: 10px; font-weight: 800; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 12px; vertical-align: middle; }
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: #fbfdff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .align-right { text-align: right; }
.data-table .actions-cell { width: 52px; text-align: right; }
.entity-cell { display: flex; align-items: center; gap: 10px; }
.entity-cell .avatar { width: 33px; height: 33px; flex-basis: 33px; color: var(--brand-deep); background: var(--brand-soft); font-size: 10px; }
.entity-cell strong, .entity-cell small { display: block; }
.entity-cell strong { max-width: 260px; overflow: hidden; color: var(--ink); text-overflow: ellipsis; font-size: 12px; }
.entity-cell small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.money { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.date-cell strong, .date-cell small { display: block; }
.date-cell strong { color: var(--text); font-weight: 600; }
.date-cell small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 10px; color: #56677a; background: #eef2f6; font-size: 9px; font-weight: 750; text-transform: uppercase; }
.tag::before { width: 5px; height: 5px; border-radius: 50%; content: ""; background: currentColor; }
.tag.open, .tag.pending, .tag.processing { color: var(--warning); background: var(--warning-soft); }
.tag.paid, .tag.authorized, .tag.active, .tag.completed { color: var(--success); background: var(--success-soft); }
.tag.overdue, .tag.failed { color: var(--danger); background: var(--danger-soft); }
.tag.cancelled, .tag.archived, .tag.ended { color: #687486; background: #edf0f4; }
.tag.draft { color: var(--purple); background: var(--purple-soft); }
.tag.paused { color: var(--warning); background: var(--warning-soft); }
.tag.not-issued, .tag.queued { color: var(--purple); background: var(--purple-soft); }
.table-footer { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; }
.pagination { display: flex; gap: 4px; }
.pagination button { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; color: var(--muted); background: #fff; font-size: 10px; }
.pagination button.active { color: #fff; border-color: var(--brand-dark); background: var(--brand-dark); }

.action-menu { position: relative; }
.action-menu-popover { position: fixed; z-index: 80; width: 218px; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: var(--shadow-md); animation: pop-in .14s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: scale(.97) translateY(-3px); } to { opacity: 1; transform: none; } }
.action-menu-popover button, .action-menu-popover a { display: flex; width: 100%; gap: 9px; align-items: center; padding: 9px 10px; border: 0; border-radius: 7px; cursor: pointer; color: var(--text); background: transparent; font-size: 11px; font-weight: 600; text-align: left; }
.action-menu-popover button:hover, .action-menu-popover a:hover { color: var(--ink); background: var(--canvas); }
.action-menu-popover svg { width: 16px; }
.action-menu-popover .danger { color: var(--danger); }
.menu-separator { height: 1px; margin: 5px 3px; background: var(--border); }

.empty-state { display: grid; min-height: 330px; place-items: center; align-content: center; padding: 40px; text-align: center; }
.empty-icon { display: inline-flex; width: 58px; height: 58px; align-items: center; justify-content: center; margin-bottom: 16px; border-radius: 17px; color: var(--brand-dark); background: var(--brand-soft); }
.empty-icon svg { width: 26px; height: 26px; }
.empty-state h3 { margin: 0 0 7px; color: var(--ink); font-size: 16px; }
.empty-state p { max-width: 350px; margin: 0 0 18px; color: var(--muted); font-size: 12px; }

.detail-layout { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 18px; }
.detail-stack { display: grid; align-content: start; gap: 18px; }
.detail-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1px; padding: 0; overflow: hidden; background: var(--border); }
.summary-item { padding: 18px; background: #fff; }
.summary-item span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.summary-item strong { color: var(--ink); font-size: 14px; }
.timeline { position: relative; display: grid; gap: 20px; }
.timeline::before { position: absolute; top: 7px; bottom: 7px; left: 7px; width: 1px; content: ""; background: var(--border-strong); }
.timeline-item { position: relative; display: grid; grid-template-columns: 16px 1fr; gap: 12px; }
.timeline-dot { z-index: 1; width: 15px; height: 15px; margin-top: 2px; border: 4px solid #fff; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px #b8daf9; }
.timeline-dot.success { background: var(--success); box-shadow: 0 0 0 1px #a9dbc9; }
.timeline-dot.danger { background: var(--danger); box-shadow: 0 0 0 1px #f2b4b9; }
.timeline-item strong { display: block; color: var(--ink); font-size: 11px; }
.timeline-item p { margin: 3px 0; color: var(--muted); font-size: 10px; }
.timeline-item time { color: var(--faint); font-size: 9px; }

.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.integration-card { overflow: hidden; }
.integration-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--border); }
.integration-identity { display: flex; gap: 13px; align-items: center; }
.integration-identity .integration-logo { width: 48px; height: 48px; font-size: 14px; }
.integration-identity h3 { margin: 0; color: var(--ink); font-size: 16px; }
.integration-identity p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.config-list { display: grid; }
.config-row { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--border); font-size: 11px; }
.config-row:last-child { border-bottom: 0; }
.config-row span { color: var(--muted); }
.config-row strong { color: var(--ink); text-align: right; }
.masked { letter-spacing: .12em; }

.settings-layout { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 18px; }
.settings-nav { align-self: start; padding: 8px; }
.settings-nav button, .settings-nav a { display: flex; width: 100%; gap: 9px; align-items: center; padding: 10px; border: 0; border-radius: 8px; cursor: pointer; color: var(--muted); background: transparent; font-size: 11px; font-weight: 650; text-align: left; }
.settings-nav button.active, .settings-nav a.active { color: var(--brand-dark); background: var(--brand-soft); }
.settings-nav svg { width: 16px; }
.settings-section { padding: 22px; }
.settings-section h3 { margin: 0 0 4px; color: var(--ink); font-size: 16px; }
.settings-section > p { margin: 0 0 24px; color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 15px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section-title { grid-column: 1/-1; margin: 9px 0 16px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--ink); font-size: 12px; }
.form-section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.checkbox-field { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 18px; color: var(--text); font-size: 11px; }
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--brand); }
.checkbox-field strong, .checkbox-field small { display: block; }
.checkbox-field strong { color: var(--ink); }
.checkbox-field small { margin-top: 2px; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 18px; border-top: 1px solid var(--border); }

.contract-table { min-width: 890px; }
.contract-table td > .tag + .tag { margin-left: 6px; }
.contract-stat .stat-value { font-variant-numeric: tabular-nums; }
.contract-status-field { align-content: start; }
.contract-current-status { display: flex; min-height: 50px; align-items: center; gap: 9px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--canvas); }
.contract-current-status small { color: var(--muted); font-size: 10px; font-weight: 450; }
.contract-cycle-note { display: flex; min-height: 50px; align-items: center; gap: 9px; margin-bottom: 18px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); background: var(--canvas); font-size: 10px; }
.contract-cycle-note svg { width: 17px; color: var(--brand-dark); }
.contract-manual-banner { margin: 0 0 18px; }
.contract-automation-option { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--brand-pale); }
.contract-fiscal-details { overflow: hidden; margin-top: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: #fbfcfe; }
.contract-fiscal-details > summary { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; cursor: pointer; list-style: none; color: var(--ink); background: #fff; }
.contract-fiscal-details > summary::-webkit-details-marker { display: none; }
.contract-fiscal-details > summary > span { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.contract-fiscal-details > summary > span > svg { grid-row: 1 / 3; width: 20px; color: var(--brand-dark); }
.contract-fiscal-details > summary strong, .contract-fiscal-details > summary small { display: block; }
.contract-fiscal-details > summary strong { font-size: 12px; }
.contract-fiscal-details > summary small { margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 450; }
.contract-fiscal-details > summary > svg { width: 17px; color: var(--muted); transition: transform .2s; }
.contract-fiscal-details[open] > summary > svg { transform: rotate(180deg); }
.contract-fiscal-grid { padding: 18px 16px 0; border-top: 1px solid var(--border); }
.contract-fiscal-review { align-items: center; padding: 12px; border: 1px solid #cce5ff; border-radius: var(--radius-sm); background: var(--brand-pale); }
.contract-fiscal-review input { flex: 0 0 auto; }
.contract-due-review .status-banner { align-items: flex-start; }
.contract-service-copy { margin: 0 0 18px; color: var(--text); white-space: pre-wrap; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 24px; background: rgba(13, 26, 43, .48); backdrop-filter: blur(3px); animation: fade-in .16s ease-out; }
@keyframes fade-in { from { opacity: 0; } }
.modal { width: min(100%, 620px); max-height: calc(100vh - 48px); overflow: hidden auto; border: 1px solid rgba(255,255,255,.4); border-radius: 15px; background: #fff; box-shadow: 0 24px 70px rgba(14,30,52,.25); animation: modal-in .18s ease-out; }
.modal-wide { width: min(100%, 780px); }
.modal-contract { width: min(100%, 940px); }
.modal-small { width: min(100%, 440px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-head { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 18px 21px; border-bottom: 1px solid var(--border); background: #fff; }
.modal-head h2 { margin: 0; color: var(--ink); font-size: 17px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.modal-body { padding: 21px; }
.modal-foot { position: sticky; z-index: 2; bottom: 0; display: flex; justify-content: flex-end; gap: 9px; padding: 14px 21px; border-top: 1px solid var(--border); background: #fff; }
.confirm-icon { display: inline-flex; width: 52px; height: 52px; align-items: center; justify-content: center; margin-bottom: 15px; border-radius: 15px; color: var(--danger); background: var(--danger-soft); }
.confirm-icon svg { width: 24px; height: 24px; }
.confirm-copy h3 { margin: 0 0 8px; color: var(--ink); font-size: 17px; }
.confirm-copy p { margin: 0; color: var(--muted); font-size: 12px; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--canvas); }
.segmented button { min-height: 30px; padding: 4px 10px; border: 0; border-radius: 6px; cursor: pointer; color: var(--muted); background: transparent; font-size: 10px; font-weight: 700; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: var(--shadow-xs); }

.toast-region { position: fixed; z-index: 200; top: 18px; right: 18px; display: grid; width: min(380px, calc(100vw - 36px)); gap: 9px; pointer-events: none; }
.toast { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 13px 14px; border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: 10px; color: var(--text); background: #fff; box-shadow: var(--shadow-md); pointer-events: auto; animation: toast-in .24s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast > svg { width: 18px; color: var(--brand-dark); }
.toast.success > svg { color: var(--success); }
.toast.error > svg { color: var(--danger); }
.toast.warning > svg { color: var(--warning); }
.toast strong, .toast small { display: block; }
.toast strong { color: var(--ink); font-size: 11px; }
.toast small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.toast button { width: 24px; height: 24px; flex-basis: 24px; }

.audit-event { display: flex; gap: 10px; align-items: center; }
.audit-icon { display: inline-flex; width: 31px; height: 31px; align-items: center; justify-content: center; border-radius: 8px; color: var(--brand-dark); background: var(--brand-soft); }
.audit-icon svg { width: 15px; }
.audit-event strong, .audit-event small { display: block; }
.audit-event strong { color: var(--ink); font-size: 11px; }
.audit-event small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.job-list { display: grid; gap: 9px; }
.job-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 9px; }
.job-row.failed { border-color: #f6c9ce; background: #fffbfb; }
.job-icon { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 9px; color: var(--purple); background: var(--purple-soft); }
.job-icon svg { width: 16px; }
.job-row strong, .job-row small { display: block; }
.job-row strong { color: var(--ink); font-size: 11px; }
.job-row small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.sidebar-scrim { display: none; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .integration-grid { grid-template-columns: 1fr; }
  .contract-stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 920px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .login-form-panel { padding: 42px 24px; }
  .login-logo-mobile { display: block; }
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-md); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .sidebar-scrim { position: fixed; z-index: 29; inset: 0; display: block; visibility: hidden; opacity: 0; background: rgba(16,29,47,.35); transition: opacity .25s, visibility .25s; }
  .sidebar-scrim.open { visibility: visible; opacity: 1; }
  .app-main { margin-left: 0; }
  .sidebar-open { display: inline-flex; }
  .global-search { display: none; }
  .topbar-user span:not(.avatar) { display: none; }
  .topbar-user > svg { display: none; }
  .detail-layout { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { display: flex; overflow-x: auto; }
  .settings-nav button { width: auto; white-space: nowrap; }
}

@media (max-width: 680px) {
  :root { --topbar-height: 68px; }
  .topbar { gap: 9px; padding: 0 15px; }
  .topbar-title p { display: none; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-actions { gap: 3px; }
  .topbar-user { margin-left: 0; }
  .main-content { padding: 22px 14px 40px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions .btn { flex: 1; }
  .status-banner { align-items: flex-start; }
  .status-banner .banner-action { display: none; }
  .stat-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { min-height: 122px; padding: 17px; }
  .stat-value { margin-top: 14px; }
  .card-head { padding: 13px 15px; }
  .card-body { padding: 15px; }
  .cash-chart { gap: 4px; }
  .table-toolbar { align-items: stretch; }
  .toolbar-search { width: 100%; }
  .filter-select { flex: 1; min-width: 125px; }
  .result-count { width: 100%; }
  .detail-summary { grid-template-columns: 1fr; }
  .integration-hero { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .contract-stat-grid { grid-template-columns: 1fr; }
  .contract-current-status { align-items: flex-start; flex-direction: column; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .modal-head, .modal-body, .modal-foot { padding-left: 17px; padding-right: 17px; }
  .toast-region { top: 10px; right: 10px; width: calc(100vw - 20px); }
}

@media print {
  .sidebar, .topbar, .page-heading .heading-actions, .table-toolbar { display: none !important; }
  .app-main { margin: 0; }
  .main-content { padding: 0; }
  .card { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
