/* The Base | Dashboard (Frontend)
 * Palette: red / black / grey
 */

:root {
  --red: #ff0000;
  --red-700: #cc0000;
  --black: #0a0a0a;
  --white: #ffffff;

  --gray-950: #0b0b0b;
  --gray-900: #141414;
  --gray-800: #222222;
  --gray-700: #343434;
  --gray-600: #5b5b5b;
  --gray-500: #7a7a7a;
  --gray-400: #a7a7a7;
  --gray-300: #e5e5e5;
  --gray-200: #f2f2f2;

  --bg: #f6f6f7;
  --card: #ffffff;
  --border: rgba(10, 10, 10, 0.08);
  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.03);
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.12);

  --radius: 18px;
  --radius-sm: 14px;

  --max: 1560px;
  --trans: 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  --focus: 0 0 0 3px rgba(255, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--gray-900);
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(255, 0, 0, 0.18), transparent 62%),
    radial-gradient(700px 500px at 98% -25%, rgba(0, 0, 0, 0.10), transparent 60%),
    linear-gradient(#fbfbfc, #f4f4f6);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

.muted {
  color: var(--gray-600);
}

/* Buttons */
.btn {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--white);
  color: var(--gray-900);
  cursor: pointer;
  transition: transform var(--trans), background var(--trans), border-color var(--trans), box-shadow var(--trans),
    color var(--trans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: linear-gradient(180deg, var(--red), var(--red-700));
  color: var(--white);
  box-shadow: 0 10px 24px rgba(255, 0, 0, 0.18);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(255, 0, 0, 0.22);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(10, 10, 10, 0.10);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(10, 10, 10, 0.16);
}

.icon-btn {
  width: 44px;
  padding: 0;
}

/* Inputs */
.input {
  height: 40px;
  width: 100%;
  border: 1px solid rgba(10, 10, 10, 0.12);
  border-radius: 12px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--gray-900);
  outline: none;
  transition: box-shadow var(--trans), border-color var(--trans), background var(--trans);
}

.input:focus {
  border-color: rgba(255, 0, 0, 0.38);
  box-shadow: var(--focus);
  background: var(--white);
}

.input--range {
  cursor: pointer;
}

.input--button {
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.input--button svg {
  flex-shrink: 0;
  opacity: 0.75;
}

/* View Containers */
.view {
  min-height: 100vh;
  display: flex;
}

/* Login */
.view--login {
  position: relative;
  align-items: center;
  justify-content: center;
  padding: 42px 18px;
  background:
    radial-gradient(900px 520px at 18% 10%, rgba(255, 0, 0, 0.28), transparent 62%),
    radial-gradient(800px 540px at 94% 0%, rgba(255, 255, 255, 0.08), transparent 55%),
    linear-gradient(180deg, #070707, #121212);
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-orb {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
}

.login-orb--1 {
  top: -180px;
  left: -140px;
  background: rgba(255, 0, 0, 0.9);
}

.login-orb--2 {
  bottom: -220px;
  right: -220px;
  background: rgba(255, 0, 0, 0.45);
}

.login-orb--3 {
  top: 12%;
  right: 6%;
  width: 360px;
  height: 360px;
  background: rgba(255, 255, 255, 0.10);
}

.login-shell {
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 16px;
}

.login-logo {
  width: 138px;
  height: auto;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35));
}

.login-title {
  color: var(--white);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 600;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.login-card {
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: rgba(10, 10, 10, 0.58);
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  margin-top: 12px;
}

.form-error {
  min-height: 18px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--red-700);
  text-align: center;
}

/* App Shell */
.view--app {
  width: 100%;
  align-items: stretch;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 16px;
  border-right: 1px solid rgba(10, 10, 10, 0.10);
  background: rgba(255, 255, 255, 0.64);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 18px;
  border: 1px solid rgba(10, 10, 10, 0.10);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}

.sidebar__logo {
  height: 48px;
  width: auto;
  flex-shrink: 0;
}

.sidebar__brandText {
  min-width: 0;
  line-height: 1.05;
}

.sidebar__name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 900;
  color: rgba(10, 10, 10, 0.62);
}

.sidebar__sub {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--gray-950);
}

.sidebar__brandText > .sidebar__sub:first-child {
  margin-top: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(10, 10, 10, 0.10);
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-800);
  background: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge--ghost {
  background: rgba(255, 255, 255, 0.65);
}

.badge--muted {
  color: var(--gray-600);
  background: rgba(242, 242, 242, 0.8);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(10, 10, 10, 0.08);
  background: rgba(255, 255, 255, 0.70);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.06);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  height: 44px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--gray-800);
  padding: 0 12px 0 26px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: background var(--trans), border-color var(--trans), color var(--trans), transform var(--trans),
    box-shadow var(--trans);
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.26);
  opacity: 0.35;
}

.nav-item:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: rgba(255, 0, 0, 0.30);
}

.nav-item:focus {
  outline: none;
}

.nav-item:hover {
  border-color: rgba(255, 0, 0, 0.18);
  background: rgba(255, 0, 0, 0.04);
}

.nav-item.active {
  background: linear-gradient(180deg, rgba(255, 0, 0, 0.14), rgba(255, 0, 0, 0.06));
  border-color: rgba(255, 0, 0, 0.22);
  color: var(--gray-950);
  box-shadow: 0 10px 24px rgba(255, 0, 0, 0.10);
}

.nav-item.active::before {
  background: var(--red);
  opacity: 1;
}

.sidebar__status {
  margin-top: auto;
  padding: 12px 10px;
  border-radius: 18px;
  border: 1px solid rgba(10, 10, 10, 0.08);
  background: rgba(242, 242, 242, 0.55);
}

.sidebar__badges {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  border-bottom: 1px solid rgba(10, 10, 10, 0.10);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
}

.topbar__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.topbar__filters {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(220px, 320px) 1fr;
  align-items: end;
  column-gap: 14px;
  row-gap: 10px;
}

.topbar__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 2px;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.filter--date {
  width: auto;
  min-width: 0;
}

.filter--accounts {
  width: auto;
  min-width: 0;
}

.filter__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 900;
  color: rgba(10, 10, 10, 0.58);
}

.filter__control {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.filter__control--date {
  gap: 8px;
}

.presets {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(10, 10, 10, 0.10);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
}

.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--gray-800);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: background var(--trans), color var(--trans), transform var(--trans), box-shadow var(--trans);
}

.chip:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.chip:focus {
  outline: none;
}

.chip:hover {
  background: rgba(255, 0, 0, 0.06);
}

.chip.chip--active {
  background: linear-gradient(180deg, rgba(255, 0, 0, 0.96), rgba(204, 0, 0, 0.96));
  color: var(--white);
  box-shadow: 0 10px 22px rgba(255, 0, 0, 0.18);
}

/* Main */
.main {
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 18px;
}

.tab-panel {
  padding-bottom: 28px;
}

.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.grid--metrics {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Auto-fit metrics so 2/3/4 cards per row look intentional. */
.grid--metrics .metric {
  grid-column: auto;
}

.grid--charts {
  grid-template-columns: repeat(12, 1fr);
}

.grid--charts .card {
  grid-column: span 6;
}

.grid--charts-3 .card {
  grid-column: span 4;
}

.chart-card--wide {
  grid-column: span 12 !important;
}

.card {
  padding: 16px;
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card__title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.58);
}

/* Metrics */
.metric {
  position: relative;
  overflow: hidden;
}

.metric__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric__label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.58);
}

.metric__pill {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 0, 0, 0.08);
  border: 1px solid rgba(255, 0, 0, 0.18);
  color: var(--gray-900);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.metric__value {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.metric__sub {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(10, 10, 10, 0.55);
}

.metric__bg {
  position: absolute;
  right: -20px;
  bottom: -18px;
  width: 220px;
  height: 120px;
  opacity: 0.18;
  pointer-events: none;
}

.metric--hero {
  border-color: rgba(255, 0, 0, 0.18);
  background:
    radial-gradient(900px 240px at 10% 30%, rgba(255, 255, 255, 0.24), transparent 55%),
    linear-gradient(180deg, var(--red), var(--red-700));
}

.metric--hero .metric__label,
.metric--hero .metric__sub,
.metric--hero .metric__pill {
  color: rgba(255, 255, 255, 0.86);
}

.metric--hero .metric__pill {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.metric--hero .metric__value {
  color: var(--white);
}

.metric--accent {
  border-color: rgba(255, 0, 0, 0.18);
}

.metric--warn {
  border-color: rgba(255, 0, 0, 0.22);
  background: linear-gradient(180deg, rgba(255, 0, 0, 0.06), rgba(255, 0, 0, 0.02));
}

/* Charts */
.chart {
  width: 100%;
  height: 280px;
}

.chart--lg {
  height: 360px;
}

.chart-empty {
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(10, 10, 10, 0.18);
  border-radius: 14px;
  background: rgba(242, 242, 242, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
  color: var(--gray-600);
  font-weight: 800;
}

/* Lists */
.list {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 1px solid rgba(10, 10, 10, 0.06);
  font-size: 13px;
  font-weight: 700;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row > div:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row > div:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--gray-700);
  text-align: right;
}

/* Section Headings */
.section-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 18px 2px 10px;
}

.section-head__title {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.64);
}

.section-head__hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
}

.section-head--spaced {
  margin-top: 22px;
}

/* Split component */
.split {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 6px 2px;
}

.split__divider {
  width: 1px;
  height: 54px;
  background: rgba(10, 10, 10, 0.10);
}

.split__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.split__label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.58);
}

.split__value {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.split__sub {
  font-size: 12px;
  font-weight: 800;
  color: var(--gray-600);
}

/* Mini KPIs */
.mini-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 2px;
  margin-bottom: 10px;
}

.mini-kpi {
  border: 1px solid rgba(10, 10, 10, 0.08);
  border-radius: 14px;
  padding: 10px 10px;
  background: rgba(242, 242, 242, 0.55);
}

.mini-kpi__label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.58);
}

.mini-kpi__value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.mini-kpi__sub {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 800;
  color: var(--gray-600);
}

/* Loading + Toast */
.loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(245, 245, 246, 0.65);
  backdrop-filter: blur(6px);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(10, 10, 10, 0.10);
  border-top-color: var(--red);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading__text {
  font-size: 13px;
  font-weight: 900;
  color: var(--gray-700);
  letter-spacing: 0.02em;
}

.toast {
  position: fixed;
  right: 16px;
  top: 92px;
  z-index: 250;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(10, 10, 10, 0.12);
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 800;
}

.toast--error {
  border-color: rgba(255, 0, 0, 0.24);
}

/* Modal (Accounts) */
.modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.38);
}

.modal__panel {
  width: min(720px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(10, 10, 10, 0.10);
}

.modal__title {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.64);
}

.modal__body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.checklist {
  display: grid;
  gap: 8px;
}

.check-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(10, 10, 10, 0.08);
  background: rgba(242, 242, 242, 0.55);
}

.check-row:hover {
  border-color: rgba(255, 0, 0, 0.18);
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--red);
}

.check-row span {
  font-size: 13px;
  font-weight: 800;
  color: var(--gray-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal__foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(10, 10, 10, 0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal__bulk,
.modal__actions {
  display: flex;
  gap: 8px;
}

/* AI Drawer */
.ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(0, 0, 0, 0.25);
}

.ai-drawer {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: 390px;
  max-width: calc(100vw - 28px);
  z-index: 900;
  background: rgba(255, 255, 255, 0.96);
  border-left: 1px solid rgba(10, 10, 10, 0.10);
  box-shadow: -20px 0 70px rgba(0, 0, 0, 0.20);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-head {
  padding: 14px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(10, 10, 10, 0.08);
}

.ai-head__title {
  font-weight: 900;
  letter-spacing: -0.02em;
}

.ai-status {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--gray-600);
}

.ai-status.success {
  color: #0b6b3a;
}

.ai-status.error {
  color: var(--red-700);
}

.ai-status.warning {
  color: #b45309;
}

.ai-status.muted {
  color: var(--gray-500);
}

.ai-status.thinking {
  color: var(--gray-800);
}

.ai-messages {
  padding: 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.ai-message {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-bubble {
  max-width: 96%;
  border-radius: 14px;
  border: 1px solid rgba(10, 10, 10, 0.08);
  padding: 10px 12px;
  background: rgba(242, 242, 242, 0.65);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  white-space: pre-wrap;
}

.ai-bubble.user {
  align-self: flex-end;
  background: rgba(255, 0, 0, 0.06);
  border-color: rgba(255, 0, 0, 0.18);
}

.ai-bubble.assistant {
  align-self: flex-start;
}

.ai-open-chart-link {
  align-self: flex-start;
  background: transparent;
  border: none;
  padding: 0 2px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  color: var(--red-700);
  text-decoration: underline;
}

.ai-open-chart-link:hover {
  color: var(--red);
}

.ai-compose {
  border-top: 1px solid rgba(10, 10, 10, 0.08);
  padding: 12px 12px;
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  align-items: end;
}

.ai-compose textarea {
  min-height: 42px;
  max-height: 180px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(10, 10, 10, 0.12);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
}

.ai-compose textarea:focus {
  border-color: rgba(255, 0, 0, 0.38);
  box-shadow: var(--focus);
}

/* AI Chart Modal */
.ai-chart-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.45);
  padding: 18px;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.ai-chart-modal__panel {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 140px rgba(0, 0, 0, 0.45);
}

.ai-chart-modal__head {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(10, 10, 10, 0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-chart-modal__title {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.64);
}

.ai-chart-full {
  flex: 1;
  min-height: 0;
  padding: 12px;
  background:
    radial-gradient(900px 360px at 12% 10%, rgba(255, 0, 0, 0.08), transparent 62%),
    linear-gradient(#fbfbfc, #f3f3f5);
}

.ai-chart-modal__foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(10, 10, 10, 0.10);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.ai-chart-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-chart-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.ai-chart-control > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 900;
  color: rgba(10, 10, 10, 0.58);
}

.ai-chart-control select {
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(10, 10, 10, 0.12);
  background: rgba(255, 255, 255, 0.92);
  padding: 0 10px;
  outline: none;
}

.ai-chart-control select:focus {
  border-color: rgba(255, 0, 0, 0.38);
  box-shadow: var(--focus);
}

.ai-chart-actions {
  display: flex;
  gap: 10px;
}

.ai-chart-canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border-radius: 16px;
  border: 1px solid rgba(10, 10, 10, 0.10);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.08);
}

.ai-chart-error {
  width: 100%;
  height: 100%;
  min-height: 160px;
  border-radius: 16px;
  border: 1px dashed rgba(10, 10, 10, 0.18);
  background: rgba(242, 242, 242, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--gray-600);
}

/* AI fallback chart (pure CSS/SVG) */
.ai-chart-canvas.ai-chart-fallback {
  padding: 14px;
  overflow: auto;
}

.ai-fb-row {
  display: grid;
  grid-template-columns: minmax(160px, 32%) 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 2px;
}

.ai-fb-label {
  font-size: 13px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gray-800);
}

.ai-fb-bar-wrap {
  height: 16px;
  background: rgba(10, 10, 10, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.ai-fb-bar {
  height: 100%;
  background: linear-gradient(180deg, var(--red), var(--red-700));
}

.ai-fb-value {
  font-size: 12px;
  font-weight: 900;
  color: var(--gray-600);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ai-fb-pie-layout {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(320px, 520px);
  gap: 18px;
  align-items: start;
  justify-content: center;
}

.ai-fb-pie-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ai-fb-pie {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 1px solid rgba(10, 10, 10, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.ai-fb-pie-hole {
  width: 54%;
  height: 54%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(10, 10, 10, 0.10);
  position: relative;
  left: 23%;
  top: 23%;
}

.ai-fb-pie-total {
  font-size: 12px;
  font-weight: 900;
  color: var(--gray-600);
}

.ai-fb-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-fb-legend-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  align-items: center;
}

.ai-fb-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14);
}

.ai-fb-legend-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--gray-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-fb-legend-value {
  font-size: 12px;
  font-weight: 900;
  color: var(--gray-600);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ai-fb-line-svg {
  width: 100%;
  min-height: 260px;
  border: 1px solid rgba(10, 10, 10, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
}

/* Flatpickr theming */
.flatpickr-calendar {
  font-family: inherit;
  border-radius: 16px;
  border: 1px solid rgba(10, 10, 10, 0.10);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.18);
}

.flatpickr-day.today {
  border-color: rgba(255, 0, 0, 0.35);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--red);
  border-color: var(--red);
}

.flatpickr-day.inRange {
  background: rgba(255, 0, 0, 0.10);
  border-color: rgba(255, 0, 0, 0.10);
  box-shadow: none;
}

.flatpickr-day:hover {
  background: rgba(255, 0, 0, 0.08);
}

/* Responsive */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid rgba(10, 10, 10, 0.10);
  }

  .sidebar__brand {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .sidebar__nav {
    flex: 1 1 auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sidebar__nav::-webkit-scrollbar {
    height: 0;
  }

  .sidebar__status {
    display: none;
  }

  .nav-item {
    width: auto;
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(10, 10, 10, 0.12);
    background: rgba(255, 255, 255, 0.78);
    justify-content: center;
  }

  .nav-item::before {
    display: none;
  }

  .topbar__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topbar__filters {
    grid-template-columns: 1fr;
  }

  .grid--metrics .metric {
    grid-column: span 6;
  }

  .grid--charts .card {
    grid-column: span 12;
  }

  .mini-kpis {
    grid-template-columns: 1fr;
  }

  .ai-fb-pie-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    flex-wrap: wrap;
  }

  .sidebar__nav {
    width: 100%;
  }

  .nav-item {
    height: 38px;
    padding: 0 12px;
  }

  .main {
    padding: 14px;
  }

  .grid--metrics .metric {
    grid-column: span 12;
  }

  .login-actions {
    grid-template-columns: 1fr;
  }

  .ai-drawer {
    width: 100%;
    max-width: 100%;
  }

  .ai-compose {
    grid-template-columns: 1fr;
  }

  .ai-chart-controls {
    width: 100%;
  }

  .ai-chart-control {
    min-width: 0;
    width: 100%;
  }

  .ai-chart-actions {
    width: 100%;
  }

  .ai-chart-actions .btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .ai-compose {
    padding-left: 10px;
    padding-right: 10px;
  }

  .ai-compose textarea {
    width: 100%;
  }
}
