:root {
  color-scheme: dark;
  --bg: #080b13;
  --surface: #0f1420;
  --surface-2: #141a28;
  --surface-3: #1a2232;
  --border: #242d3f;
  --border-soft: #1d2534;
  --text: #f2f5fa;
  --muted: #8994a8;
  --violet: #806cf5;
  --cyan: #35c3d7;
  --amber: #f0ae4a;
  --green: #46c995;
  --red: #f16e78;
  --sidebar: 242px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 0.85fr) 1.15fr;
  background: #090d16;
}

.login-card {
  width: min(430px, calc(100% - 56px));
  margin: auto;
  padding: 48px 0;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(145deg, #927fff, #6554d9);
  box-shadow: 0 10px 30px rgba(128, 108, 245, .28);
}
.brand div { display: grid; gap: 1px; }
.brand strong { font-size: 14px; letter-spacing: .01em; }
.brand span:last-child { color: var(--muted); font-size: 11px; }
.brand-login { margin-bottom: 84px; }

.eyebrow {
  margin: 0 0 10px; color: #9d90fa; font-size: 11px;
  font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(30px, 3vw, 42px); line-height: 1.08; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.muted { color: var(--muted); line-height: 1.6; }
.login-card > .muted { margin-bottom: 36px; }
form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; color: #b9c1cf; font-size: 12px; font-weight: 650; }
input, select {
  width: 100%; border: 1px solid var(--border); border-radius: 9px;
  background: #0d121d; color: var(--text); outline: none;
  padding: 12px 13px; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(128,108,245,.15); }
.form-error { margin: 0; color: #ff9199; font-size: 13px; }
.button {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center;
  gap: 14px; border: 0; border-radius: 9px; padding: 0 16px; cursor: pointer;
  color: var(--text); font-weight: 750; text-decoration: none;
}
.button:disabled { opacity: .55; cursor: wait; }
.button-primary {
  justify-content: space-between; margin-top: 3px; padding: 0 18px;
  background: linear-gradient(135deg, #806cf5, #6d5adb);
  box-shadow: 0 12px 28px rgba(101, 84, 217, .25);
}
.button-secondary { border: 1px solid var(--border); background: var(--surface-2); }
.security-note { margin-top: 25px; color: #647084; font-size: 11px; text-align: center; }
.security-note span { color: var(--green); margin-right: 5px; }

.login-aside {
  position: relative; min-height: 100%; overflow: hidden;
  background:
    linear-gradient(135deg, rgba(7,11,19,.12), rgba(7,11,19,.6)),
    radial-gradient(circle at 20% 20%, #253052 0, #141c30 32%, #0b0f19 72%);
}
.login-aside::before {
  content: ""; position: absolute; inset: 0; opacity: .3;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 44px 44px;
}
.ambient { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .4; }
.ambient-one { width: 340px; height: 340px; background: #664bdc; top: 12%; right: 10%; }
.ambient-two { width: 280px; height: 280px; background: #147f98; bottom: 12%; left: 14%; }
.preview-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-2deg);
  width: min(560px, 72%); padding: 32px; border-radius: 18px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(13,18,30,.72);
  backdrop-filter: blur(18px); box-shadow: 0 40px 90px rgba(0,0,0,.42);
}
.preview-label { color: #9aa6ba; font-size: 12px; }
.preview-card > strong { display: block; margin: 10px 0 34px; font-size: 32px; }
.preview-chart { height: 170px; display: flex; align-items: end; gap: 12px; border-bottom: 1px solid #2c3549; }
.preview-chart i {
  flex: 1; height: var(--h); border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #8975f8, rgba(128,108,245,.15));
}

.app-view { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar);
  background: #0b101a; border-right: 1px solid var(--border-soft);
  padding: 24px 16px; display: flex; flex-direction: column;
}
.sidebar .brand { padding: 0 9px; margin-bottom: 42px; }
nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 13px; min-height: 42px;
  padding: 0 12px; border-radius: 8px; color: #8e99ac;
  font-size: 13px; font-weight: 600; text-decoration: none;
}
.nav-item > span { width: 18px; text-align: center; color: #727d92; font-size: 17px; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.025); }
.nav-item.active { color: #f0edff; background: rgba(128,108,245,.12); }
.nav-item.active > span { color: #9d8df8; }
.nav-heading { margin: 26px 12px 8px; color: #515d72; font-size: 9px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.legacy-status {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px; border: 1px solid var(--border-soft); border-radius: 9px;
  background: rgba(255,255,255,.018);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(70,201,149,.1); }
.legacy-status div { display: grid; gap: 2px; }
.legacy-status strong { font-size: 11px; }
.legacy-status span:last-child { color: var(--muted); font-size: 9px; }

.workspace { min-height: 100vh; margin-left: var(--sidebar); background: #090d15; }
.topbar {
  height: 67px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-soft); background: rgba(9,13,21,.92);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px);
}
.breadcrumb { display: flex; gap: 9px; align-items: center; color: #5d687a; font-size: 11px; }
.breadcrumb b { color: #333d4e; }
.breadcrumb strong { color: #a6afbe; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.environment-badge {
  display: flex; gap: 7px; align-items: center; margin-right: 6px;
  border: 1px solid #283244; border-radius: 99px; padding: 5px 10px;
  color: #8f9aad; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
}
.environment-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.icon-button {
  width: 34px; height: 34px; border: 1px solid var(--border-soft); border-radius: 8px;
  background: transparent; color: #8792a5; cursor: pointer;
}
.user-chip { border: 0; background: transparent; color: var(--text); display: flex; align-items: center; gap: 9px; cursor: pointer; text-align: left; }
.user-chip > span:first-child {
  width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px;
  background: #28243e; color: #b4a9ff; font-size: 10px; font-weight: 800;
}
.user-chip > span:last-child { display: grid; gap: 1px; }
.user-chip strong { font-size: 10px; }
.user-chip small { color: var(--muted); font-size: 8px; }
.menu-button { display: none; }

.content { padding: 34px 34px 55px; max-width: 1600px; margin: auto; }
.page-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 28px; }
.page-heading h1 { font-size: 30px; }
.page-heading .muted { margin: 8px 0 0; font-size: 12px; }
.heading-actions { display: flex; align-items: end; gap: 10px; }
.select-label { min-width: 150px; color: #6f7a8e; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.select-label select { margin-top: 1px; padding: 10px 12px; font-size: 11px; text-transform: none; letter-spacing: 0; }
.notice { margin-bottom: 20px; padding: 12px 14px; border-radius: 8px; font-size: 12px; }
.notice-error { border: 1px solid rgba(241,110,120,.25); background: rgba(241,110,120,.08); color: #ff9ca4; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi-card {
  min-height: 132px; padding: 18px; border: 1px solid var(--border-soft);
  border-radius: 10px; background: linear-gradient(145deg, #111722, #0e131e);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; color: #838ea0; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.kpi-top i { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-style: normal; font-size: 10px; }
.kpi-card > strong { display: block; font-size: 25px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi-card > small { color: #687487; font-size: 9px; }
.accent-violet .kpi-top i { color: #ad9fff; background: rgba(128,108,245,.13); }
.accent-cyan .kpi-top i { color: #65d8e7; background: rgba(53,195,215,.12); }
.accent-amber .kpi-top i { color: #f5c36e; background: rgba(240,174,74,.12); }
.accent-green .kpi-top i { color: #73dfb3; background: rgba(70,201,149,.12); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .78fr); gap: 12px; margin-bottom: 12px; }
.panel { border: 1px solid var(--border-soft); border-radius: 10px; background: #0e131d; }
.panel-heading { min-height: 67px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-soft); }
.panel-heading p { margin: 4px 0 0; color: #687487; font-size: 9px; }
.panel-heading a { color: #9484f6; font-size: 10px; text-decoration: none; }
.legend { color: #758094; font-size: 9px; }
.legend i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 2px; background: var(--violet); }
.trend-chart { height: 248px; padding: 22px 18px 15px; display: flex; align-items: end; gap: 7px; }
.trend-bar {
  flex: 1; min-width: 3px; height: var(--height); min-height: 2px; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #8f7bf8, #5244a5); position: relative; opacity: .85;
}
.trend-bar:hover { opacity: 1; }
.trend-bar span {
  display: none; position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  white-space: nowrap; padding: 5px 7px; border-radius: 5px; background: #222a3a; color: #dfe4ed; font-size: 8px;
}
.trend-bar:hover span { display: block; }
.chart-empty { margin: auto; color: #596477; font-size: 11px; }
.health-list { margin: 0; padding: 8px 18px; }
.health-list div { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
.health-list dt { color: #8792a5; font-size: 10px; }
.health-list dd { margin: 0; font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.health-callout { display: flex; gap: 10px; align-items: start; margin: 10px 12px 12px; padding: 12px; border-radius: 8px; background: rgba(70,201,149,.06); border: 1px solid rgba(70,201,149,.12); }
.health-callout > span { color: var(--green); }
.health-callout p { display: grid; gap: 2px; margin: 0; }
.health-callout strong { font-size: 10px; }
.health-callout small { color: #718075; font-size: 8px; line-height: 1.45; }

.alerts-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { color: #596579; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; text-align: left; padding: 11px 18px; background: #0b1018; }
td { padding: 13px 18px; border-top: 1px solid var(--border-soft); color: #aab3c2; }
td:first-child { color: #e2e6ed; font-weight: 650; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 4px 8px; font-size: 8px; font-weight: 800; letter-spacing: .04em; }
.status-high { color: #ff9ca4; background: rgba(241,110,120,.1); }
.status-low { color: #f5c36e; background: rgba(240,174,74,.1); }
.empty-cell { padding: 35px; color: #596477; text-align: center; font-weight: 400 !important; }
.placeholder-view { min-height: calc(100vh - 67px); display: grid; place-content: center; justify-items: start; }
.placeholder-view .muted { max-width: 560px; }

.catalog-heading .button-primary { min-width: 150px; }
.catalog-toolbar {
  display: grid; grid-template-columns: minmax(220px, 1fr) 180px auto;
  align-items: end; gap: 12px; margin-bottom: 14px; padding: 14px;
}
.catalog-toolbar .button { min-height: 41px; }
.data-toolbar {
  display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  align-items: end; gap: 12px; margin-bottom: 14px; padding: 14px;
}
.accounting-toolbar { grid-template-columns: minmax(180px, .7fr) minmax(240px, 1fr) auto; }
.reports-toolbar { grid-template-columns: repeat(4, minmax(135px, 1fr)) auto; }
.data-toolbar .button { min-height: 41px; }
.data-panel { overflow: hidden; }
.report-kpis { margin-top: 0; }
.report-kpis .kpi-card { min-height: 105px; }
.report-kpis .kpi-top { margin-bottom: 10px; }
.data-panel td { white-space: nowrap; }
.catalog-panel { overflow: hidden; }
.catalog-pagination {
  min-height: 62px; padding: 11px 16px; display: flex; align-items: center;
  justify-content: space-between; border-top: 1px solid var(--border-soft);
  color: var(--muted); font-size: 10px;
}
.catalog-pagination > div { display: flex; align-items: center; gap: 12px; }
.catalog-pagination .button { min-height: 34px; font-size: 10px; }
.table-action {
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px;
  background: var(--surface-2); color: #bcb3fa; font-size: 9px; cursor: pointer;
}
.table-action:hover { border-color: var(--violet); }
.table-action + .table-action { margin-left: 6px; }
.table-action-danger { color: #ff9ca4; }
.catalog-dialog {
  width: min(620px, calc(100% - 28px)); max-height: calc(100vh - 40px);
  padding: 0; border: 1px solid var(--border); border-radius: 13px;
  background: #0d121d; color: var(--text); box-shadow: 0 30px 90px rgba(0,0,0,.65);
}
.catalog-dialog::backdrop { background: rgba(3,6,11,.76); backdrop-filter: blur(4px); }
.transactions-dialog { width: min(1200px, 95vw); max-width: 95vw; }
.transactions-dialog td { white-space: normal; overflow-wrap: anywhere; }
.catalog-dialog form { display: block; }
.catalog-dialog header, .catalog-dialog footer {
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between;
}
.catalog-dialog header { border-bottom: 1px solid var(--border-soft); }
.catalog-dialog header h2 { font-size: 18px; }
.catalog-dialog footer { justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border-soft); }
.catalog-dialog footer .button { min-width: 100px; }
.catalog-fields { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.catalog-fields label:has(input[name="name"]),
.catalog-fields label:has(input[name="slug"]),
.catalog-fields label:has(select[name="providerId"]) { grid-column: 1 / -1; }
.checkbox-field {
  min-height: 43px; display: flex; flex-direction: row; align-items: center;
  gap: 10px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px;
  background: #0d121d; cursor: pointer;
}
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--violet); }
.catalog-dialog .form-error { padding: 0 20px 16px; }
.accounting-fields label:first-child { grid-column: 1 / -1; }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .health-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .health-panel .panel-heading { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .login-view { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.45); }
  .sidebar.open { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .menu-button { display: block; }
  .breadcrumb, .environment-badge, .user-chip > span:last-child { display: none; }
  .topbar { padding: 0 16px; }
  .content { padding: 26px 16px 44px; }
  .page-heading { align-items: start; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions label { flex: 1; }
  .kpi-grid { grid-template-columns: 1fr; }
  .health-panel { display: block; }
  .catalog-toolbar { grid-template-columns: 1fr; }
  .data-toolbar, .accounting-toolbar, .reports-toolbar { grid-template-columns: 1fr; }
  .catalog-pagination { align-items: start; gap: 12px; flex-direction: column; }
  .catalog-fields { grid-template-columns: 1fr; }
  .catalog-fields label { grid-column: auto !important; }
}
tfoot td { font-weight: 700; border-top: 2px solid #526485; background: #172036; }
.user-permissions { display: grid; gap: 12px; padding: 12px 0; }
.users-toolbar { grid-template-columns: minmax(180px, 1fr) auto; }
#users-form fieldset, #users-form > p { margin: 16px 22px; }
.user-permissions label { display: flex; align-items: center; gap: 10px; }
.user-permissions input { width: auto; }
#users-dialog { max-height: 90vh; overflow-y: auto; }
#users-body td:nth-child(4) { white-space: normal; min-width: 200px; max-width: 360px; }
