/* ===== ContaBilè — design tokens & base (logo-aligned) ===== */
:root {
  /* Brand — from wordmark / bull assets (#242D3C family) */
  --brand-ink:   #242d3c;
  --brand-deep:  #1a2230;
  --brand-mid:   #3d4d61;
  --brand-soft:  #5c6d82;
  --brand-muted: #8b9aad;

  --navy:        var(--brand-ink);
  --navy-700:    #2f3847;
  --navy-600:    #3a4658;
  --navy-ink:    var(--brand-deep);

  /* Accent — steel blue from the logo family (overridable via tweaks) */
  --accent:      #456882;
  --accent-soft: color-mix(in oklch, var(--accent) 11%, white);
  --accent-ink:  var(--brand-ink);

  /* Semantic — muted, professional */
  --pos: #3d7260;
  --neg: #b85445;
  --neg-soft: color-mix(in oklch, var(--neg) 10%, white);
  --warn: #a67c32;
  --info: var(--accent);

  /* Chart / data palette — harmonious slate progression */
  --chart-1: var(--brand-ink);
  --chart-2: #456882;
  --chart-3: #5a7390;
  --chart-4: #70879f;
  --chart-5: #879bb0;
  --chart-6: #a3b4c4;

  /* Light surfaces */
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --surface-2: #f7f8fa;
  --line:      #e2e6eb;
  --line-2:    #eceff3;

  /* Text */
  --text:      var(--brand-ink);
  --text-2:    #4f5d6e;
  --text-3:    var(--brand-muted);
  --on-navy:   #eef1f5;
  --on-navy-2: #9aa6b8;

  /* Type */
  --font-ui:  "Schibsted Grotesk", system-ui, sans-serif;
  --font-mono:"Geist Mono", ui-monospace, "SF Mono", monospace;

  /* Geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(28,38,54,.05), 0 1px 3px rgba(28,38,54,.04);
  --shadow:    0 1px 2px rgba(28,38,54,.04), 0 8px 24px -12px rgba(28,38,54,.16);
  --shadow-lg: 0 24px 60px -24px rgba(28,38,54,.34);

  /* Density */
  --gap: 20px;
  --card-pad: 22px;
  --row-h: 52px;
  --sidebar-w: 256px;
}

[data-density="compact"] {
  --gap: 14px;
  --card-pad: 16px;
  --row-h: 44px;
}
[data-density="comfy"] {
  --gap: 26px;
  --card-pad: 28px;
  --row-h: 60px;
}

[data-theme="dark"] {
  --bg:        #12161c;
  --surface:   #181e26;
  --surface-2: #1c232c;
  --line:      #2a3340;
  --line-2:    #232b36;
  --text:      #e8ecf1;
  --text-2:    #a3aebd;
  --text-3:    #6f7b8b;
  --navy:      var(--brand-deep);
  --navy-700:  #1f2733;
  --navy-600:  #2c3645;
  --on-navy:   #e8ecf1;
  --on-navy-2: #8b97a8;
  --accent-soft: color-mix(in oklch, var(--accent) 18%, #181e26);
  --neg-soft: color-mix(in oklch, var(--neg) 14%, #181e26);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 10px 30px -16px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 70px -28px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.01em;
}
#root { height: 100%; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; letter-spacing: -0.02em; }
.tnum { font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in oklch, var(--text-3) 40%, transparent); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== App shell ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy);
  color: var(--on-navy);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
  position: relative;
  z-index: 5;
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand-bull { width: 34px; height: 34px; object-fit: contain; }
.brand-word { height: 19px; object-fit: contain; }
.brand-on-dark { filter: brightness(0) invert(1); opacity: .94; }
.brand-on-light { filter: none; opacity: 1; }

.biz-switch {
  display: flex; align-items: center; gap: 10px;
  background: var(--navy-700);
  border: 1px solid color-mix(in oklch, var(--on-navy) 9%, transparent);
  border-radius: var(--r);
  padding: 9px 11px; margin-bottom: 12px; cursor: pointer;
  transition: background .15s ease;
}
.biz-switch:hover { background: var(--navy-600); }
.biz-logo { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex: 0 0 30px; }
.biz-meta { min-width: 0; flex: 1; }
.biz-name { font-size: 13.5px; font-weight: 600; color: var(--on-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.biz-type { font-size: 11px; color: var(--on-navy-2); }

.nav-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--on-navy-2); padding: 12px 10px 5px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px;
  color: var(--on-navy-2); font-size: 14px; font-weight: 500;
  width: 100%; text-align: left; transition: background .14s ease, color .14s ease;
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-item:hover { background: color-mix(in oklch, var(--on-navy) 7%, transparent); color: var(--on-navy); }
.nav-item.active { background: rgba(255,255,255,.11); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.nav-item.active svg { color: #fff; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 99px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; }
.nav-item.active .nav-badge { background: rgba(255,255,255,.22); }

.sidebar-spacer { flex: 1; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-top: 1px solid color-mix(in oklch, var(--on-navy) 8%, transparent); margin-top: 6px; }
.avatar { border-radius: 50%; background: var(--navy-600); color: #fff; display: grid; place-items: center; font-weight: 600; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.1); }

/* Main column */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
  height: 64px; flex: 0 0 64px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 80%, transparent);
  backdrop-filter: blur(8px);
  position: relative; z-index: 4;
}
.page-title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.page-sub { font-size: 12.5px; color: var(--text-3); }
.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 13px; width: 260px; color: var(--text-3);
}
.search input { border: none; background: none; outline: none; color: var(--text); width: 100%; font-size: 13.5px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: var(--text-2); border: 1px solid transparent; position: relative;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--neg); border: 2px solid var(--surface); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-ink); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { filter: brightness(1.05); }

/* Content scroll area */
.content { flex: 1; overflow-y: auto; padding: var(--gap); scroll-behavior: smooth; }
.content-inner { max-width: 1180px; margin: 0 auto; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--card-pad);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* Grid */
.grid { display: grid; gap: var(--gap); }

/* KPI */
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi-value { font-size: 29px; font-weight: 600; letter-spacing: -0.03em; margin: 9px 0 6px; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta svg { width: 14px; height: 14px; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; line-height: 1.4; }
.badge.pos { background: color-mix(in oklch, var(--pos) 13%, transparent); color: var(--pos); }
.badge.warn { background: color-mix(in oklch, var(--warn) 15%, transparent); color: var(--warn); }
.badge.neg { background: color-mix(in oklch, var(--neg) 13%, transparent); color: var(--neg); }
.badge.info { background: color-mix(in oklch, var(--info) 13%, transparent); color: var(--info); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Lists / rows */
.row { display: flex; align-items: center; gap: 13px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.row:last-child { border-bottom: none; }
.rico { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 38px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.rico svg { width: 18px; height: 18px; }
.r-main { flex: 1; min-width: 0; }
.r-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.r-amt { font-weight: 600; font-size: 14px; }
.r-amt.neg { color: var(--neg); }
.r-amt.pos { color: var(--pos); }

/* Table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); font-weight: 600; padding: 0 14px 12px; }
.tbl td { padding: 13px 14px; border-top: 1px solid var(--line-2); font-size: 13.5px; }
.tbl tr.clickable:hover td { background: var(--surface-2); cursor: pointer; }
.tbl th.num, .tbl td.num { text-align: right; }

/* segmented */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Brand header */
.brand-header { position: relative; overflow: hidden; border-radius: var(--r-lg); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.brand-cover { height: 132px; position: relative; }
.brand-body { background: var(--surface); padding: 0 var(--card-pad) 18px; display: flex; align-items: flex-end; gap: 16px; }
.brand-logo-badge { width: 72px; height: 72px; border-radius: 16px; background: var(--surface); border: 3px solid var(--surface); box-shadow: var(--shadow); margin-top: -34px; display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; }
.brand-logo-badge img { width: 50px; height: 50px; object-fit: contain; }

/* misc */
.hl { color: var(--accent-ink); font-weight: 600; }
.divider { height: 1px; background: var(--line-2); margin: 14px 0; }
.empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 28px; }
.skel { background: linear-gradient(90deg, var(--line-2), var(--surface-2), var(--line-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* number pop */
@keyframes popIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.pop { animation: popIn .5s cubic-bezier(.2,.7,.3,1) both; }

/* view fade */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view { animation: viewIn .32s cubic-bezier(.2,.7,.3,1) both; }

/* Assistant panel */
.assistant-scrim { position: fixed; inset: 0; background: rgba(20,25,31,.34); backdrop-filter: blur(2px); z-index: 40; opacity: 0; transition: opacity .25s ease; }
.assistant-scrim.show { opacity: 1; }
.assistant {
  position: fixed; top: 0; right: 0; height: 100vh; width: 420px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--line); z-index: 41;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .34s cubic-bezier(.3,.8,.3,1);
}
.assistant.show { transform: none; }
.asst-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 11px; }
.asst-orb { width: 36px; height: 36px; border-radius: 11px; background: var(--navy); display: grid; place-items: center; flex: 0 0 auto; }
.asst-orb img { width: 24px; height: 24px; }
.asst-orb .brand-on-dark { width: 24px; height: 24px; }
.asst-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 88%; font-size: 13.5px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 14px 14px 4px 14px; }
.msg.ai { align-self: flex-start; }
.msg.ai .ai-bubble { background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 14px 14px 14px 4px; }
.asst-foot { padding: 14px; border-top: 1px solid var(--line); }
.asst-input { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 14px; }
.asst-input input { flex: 1; border: none; background: none; outline: none; color: var(--text); font-size: 13.5px; }
.chip { font-size: 12px; font-weight: 500; padding: 7px 11px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); text-align: left; transition: background .14s, border-color .14s; }
.chip:hover { background: var(--surface); border-color: var(--accent); color: var(--text); }

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing span:nth-child(2){ animation-delay: .2s; } .typing span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,60%,100%{ opacity: .25; } 30%{ opacity: 1; } }

/* Modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(20,25,31,.42); backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: center; padding: 28px; animation: viewIn .2s ease both; }
.modal { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); box-shadow: var(--shadow-lg); width: 100%; max-width: 640px; max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; animation: modalIn .3s cubic-bezier(.2,.8,.3,1) both; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* field */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .ipt { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: 13.5px; outline: none; transition: border-color .15s; }
.field .ipt:focus { border-color: var(--accent); }
.field .ipt.edited { border-color: var(--accent); background: var(--accent-soft); }

/* success check */
.check-circle { width: 56px; height: 56px; border-radius: 50%; background: var(--pos); display: grid; place-items: center; margin: 0 auto 14px; }

/* ===== Login ===== */
.login-shell { min-height: 100vh; display: flex; }
.login-brand {
  width: 42%; min-width: 320px; background: var(--navy); color: var(--on-navy);
  display: flex; flex-direction: column; justify-content: center; padding: 60px 48px;
}
.login-brand-row { margin-bottom: 32px; display: flex; align-items: center; gap: 12px; }
.login-brand-row .brand-bull { width: 44px; height: 44px; }
.login-brand-row .brand-word { height: 28px; }
.login-eyebrow {
  font-size: 11px; color: var(--brand-muted); font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: 14px;
}
.login-brand h1 { font-size: 30px; font-weight: 700; line-height: 1.2; margin: 0 0 16px; }
.login-brand h1 em { font-style: normal; color: var(--on-navy); opacity: .92; }
.login-brand p { font-size: 14px; color: var(--on-navy-2); line-height: 1.7; max-width: 340px; margin: 0; }
.login-footer { margin-top: 40px; font-size: 11px; color: var(--on-navy-2); }
.login-form-panel {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px; background: var(--bg);
}
.login-form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.login-form .lead { font-size: 14px; color: var(--text-2); margin-bottom: 28px; }
.login-error { padding: 10px 14px; border-color: var(--neg); background: var(--neg-soft); }
.login-submit { height: 46px; justify-content: center; font-size: 15px; font-weight: 700; width: 100%; }
.login-beta {
  margin-top: 24px; padding: 14px 16px;
  background: var(--surface-2); border-color: var(--line);
}
.login-loading {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px; background: var(--navy); color: var(--on-navy-2);
}
.login-loading img { height: 32px; opacity: .94; }

@media (max-width: 860px) {
  .login-shell { flex-direction: column; }
  .login-brand { width: 100%; padding: 40px 28px 32px; }
  .login-form-panel { padding: 32px 28px 48px; }
}
.check-circle svg { width: 30px; height: 30px; stroke: #fff; stroke-width: 3; fill: none; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .5s .15s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* placeholder image (striped) */
.ph { background-image: repeating-linear-gradient(135deg, var(--line-2) 0 10px, var(--surface-2) 10px 20px); display: grid; place-items: center; }
.ph .ph-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); background: var(--surface); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); }
