/* ===========================================================================
   Bokföring – Fortnox-inspirerat designspråk
   =========================================================================== */

:root {
  /* Fortnox-liknande grön palett */
  --brand: #1f9d55;
  --brand-600: #178a49;
  --brand-700: #0f6e39;
  --brand-050: #e9f7ef;
  --brand-100: #c5e8d4;

  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-2: #f7faf8;
  --border: #e6ebe8;
  --border-strong: #d3dcd7;

  --text: #17251d;
  --muted: #6b7c73;
  --muted-2: #94a29a;

  --pos: #1f9d55;
  --neg: #d64545;
  --warn: #c98a1a;

  --topbar-h: 58px;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(23, 37, 29, 0.06);
  --shadow: 0 2px 8px rgba(23, 37, 29, 0.08);
  --shadow-lg: 0 8px 28px rgba(23, 37, 29, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #35b96a;
    --brand-600: #2ba85e;
    --brand-700: #7bd6a0;
    --brand-050: #16281f;
    --brand-100: #1f3a2b;

    --bg: #0e1512;
    --panel: #16211c;
    --panel-2: #131d18;
    --border: #263630;
    --border-strong: #33473f;

    --text: #e7efea;
    --muted: #9fb0a8;
    --muted-2: #7b8c84;
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--brand-600);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---------- Layout ---------- */
.layout {
  min-height: 100vh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.body {
  display: flex;
  align-items: flex-start;
}
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
}
.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 26px 32px 60px;
}

/* ---------- Topbar ---------- */
.hamburger {
  display: none;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}
.brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.brand:hover {
  text-decoration: none;
}
/*
 * Logotypen i två utföranden, ett per tema.
 *
 * Båda ligger i markupen och CSS döljer den som inte gäller. Alternativet,
 * att byta `src` med skript, skulle ge ett synligt hopp när sidan laddas och
 * sluta fungera helt om skriptet inte hinner köra.
 */
.brand-mark {
  height: 24px;
  width: auto;
  display: block;
}
.brand-mark-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  .brand-mark-light {
    display: none;
  }
  .brand-mark-dark {
    display: block;
  }
}

.company-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  background: var(--panel);
}
.company-switch:hover {
  border-color: var(--border-strong);
  background: var(--panel-2);
}
.company-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}
.company-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.company-name {
  font-weight: 600;
  font-size: 13px;
}
.company-org {
  font-size: 11px;
  color: var(--muted);
}
.chevron {
  color: var(--muted);
  font-size: 11px;
}

.topbar-search {
  flex: 1 1 auto;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
}
.topbar-search:focus-within {
  border-color: var(--brand);
  background: var(--panel);
}
.search-icon {
  font-size: 13px;
  opacity: 0.6;
}
.topbar-search input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  font: inherit;
  color: var(--text);
  outline: none;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.year-pill-select {
  width: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-700);
  background: var(--brand-050);
  padding: 7px 12px;
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  cursor: pointer;
}
.year-pill-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-050);
}
.status-open {
  color: var(--brand-700);
  background: var(--brand-050);
  border-color: var(--brand-100);
}
.status-closed {
  color: var(--muted);
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}
.icon-btn:hover {
  background: var(--panel-2);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2b3a31;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}

/* ---------- Sidebar nav ---------- */
.nav-group {
  margin-bottom: 6px;
}
.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  padding: 14px 12px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  transition: background 0.12s;
}
.nav a:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.nav a.active {
  background: var(--brand-050);
  color: var(--brand-700);
  font-weight: 600;
}
.nav a .ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--muted);
}
.nav a.active .ico {
  color: var(--brand-600);
}
.sidebar-foot {
  margin-top: auto;
  padding: 14px 12px 4px;
  color: var(--muted);
}
.foot-title {
  font-size: 12px;
  font-weight: 600;
}
.foot-sub {
  font-size: 11px;
  color: var(--muted-2);
}

/* ---------- Headings ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 26px 0 12px;
}
.subtitle {
  color: var(--muted);
  margin: 0;
}

/* ---------- Cards & grid ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card.pad-0 {
  padding: 0;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 {
  margin: 0;
}
.card-body {
  padding: 4px 20px 8px;
}
.grid {
  display: grid;
  gap: 16px;
}
.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 1100px) {
  .cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 720px) {
  .cols-4,
  .cols-3,
  .cols-2 {
    grid-template-columns: 1fr;
  }
}

/* ---------- Stat tiles ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-ico {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--brand-050);
  color: var(--brand-600);
}
.stat-ico svg {
  width: 18px;
  height: 18px;
}
.stat .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.stat .value {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .sub {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Quick actions ---------- */
.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 720px) {
  .actions {
    grid-template-columns: repeat(2, 1fr);
  }
}
.action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s, box-shadow 0.12s, border-color 0.12s;
}
.action:hover {
  border-color: var(--brand-100);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
}
.action .a-ico {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand-050);
  color: var(--brand-600);
  display: grid;
  place-items: center;
  flex: 0 0 38px;
}
.action .a-ico svg {
  width: 20px;
  height: 20px;
}
.action .a-text b {
  display: block;
  font-weight: 700;
}
.action .a-text span {
  font-size: 12px;
  color: var(--muted);
}
.action.disabled {
  opacity: 0.55;
  cursor: default;
}
.action.disabled:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
}

/* ---------- Result bar ---------- */
.resultbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rb-track {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-2);
}
.rb-income {
  background: var(--brand);
}
.rb-expense {
  background: #e08a8a;
}
.rb-legend {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--muted);
}
.rb-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead th {
  position: sticky;
  top: 0;
}
th,
td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: var(--panel-2);
}
td.num,
th.num {
  text-align: right;
}
tbody tr:hover {
  background: var(--panel-2);
}
tbody tr:last-child td {
  border-bottom: none;
}
tr.total td {
  font-weight: 800;
  border-top: 2px solid var(--border-strong);
  background: var(--panel-2);
}
.pos {
  color: var(--pos);
}
.neg {
  color: var(--neg);
}
.muted {
  color: var(--muted);
}
.acct-no {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.badge.green {
  background: var(--brand-050);
  border-color: var(--brand-100);
  color: var(--brand-700);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-050);
  color: var(--brand-700);
  font-weight: 700;
  font-size: 12px;
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}
input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
input::placeholder {
  color: var(--muted-2);
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-050);
}
.field {
  margin-bottom: 16px;
}
.row2 {
  display: grid;
  grid-template-columns: 160px 200px 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .row2 {
    grid-template-columns: 1fr;
  }
}
.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

/* ---------- Buttons ---------- */
button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
}
button:hover {
  background: var(--panel-2);
}
button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
button.primary:hover {
  background: var(--brand-600);
}
button.primary:disabled {
  background: var(--border-strong);
  border-color: var(--border-strong);
  color: #fff;
  cursor: not-allowed;
  box-shadow: none;
}
button.ghost {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
}
button.ghost:hover {
  color: var(--neg);
  background: transparent;
}
.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------- Verification line editor ---------- */
.lines th,
.lines td {
  padding: 6px 8px;
}
.lines td:first-child,
.lines th:first-child {
  padding-left: 0;
}
.lines input {
  padding: 9px 10px;
}
.lines tbody tr:hover {
  background: transparent;
}
/* Verifikationsvy (Fortnox-lik) */
.ver-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ver-title {
  font-size: 20px;
  font-weight: 700;
}
.ver-title b {
  font-weight: 800;
}
.ver-status {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  vertical-align: middle;
}
.ver-pill {
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
}
.ver-pill.outline {
  background: var(--panel);
  color: var(--brand-700);
  border-color: var(--brand);
}
.ver-pill.list {
  background: #e8a13a;
  border-color: #e8a13a;
  color: #fff;
}
.ver-pill.grey {
  background: var(--panel-2);
  color: var(--muted);
}
.ver-pill.green {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.ver-pill.green:disabled {
  background: var(--border-strong);
  border-color: var(--border-strong);
  cursor: not-allowed;
}
.ver-subtoolbar {
  display: flex;
  gap: 4px;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.ver-tool {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: not-allowed;
  opacity: 0.75;
}
.ver-pill.danger {
  background: var(--panel);
  color: var(--neg);
  border-color: #f0c2bb;
}
.ver-pill.danger:hover {
  background: #fdf1ef;
}
.ver-status.booked {
  color: var(--brand-700);
  background: var(--brand-50, #eaf7f0);
  border-color: var(--brand);
}
.ver-card {
  max-width: 1180px;
}

/* Verifikat + kvittopanel sida vid sida (som Fortnox). */
.ver-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .ver-split {
    grid-template-columns: 1fr;
  }
}
.ver-doc {
  position: sticky;
  top: 16px;
}
.att-list {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}
.att-empty {
  margin: 0;
  font-size: 13px;
}
.att-item {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
}
.att-item img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #fff;
}
.att-pdf {
  display: grid;
  place-items: center;
  height: 120px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--neg);
  background: #fff;
}
.att-item figcaption {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.att-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-drop {
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  padding: 18px 14px;
  text-align: center;
}
.att-drop.over {
  border-color: var(--brand);
  background: var(--panel-2);
}
.att-drop p {
  margin: 0 0 10px;
  font-size: 13px;
}
.att-drop .hint {
  margin: 10px 0 0;
}
.locked-note {
  color: var(--muted);
}

/* Utkast i verifikationslistan */
.card.is-draft {
  border-left: 3px solid #e8a13a;
}
.badge.draft {
  color: #a5641a;
  border-color: #edc98f;
  background: #fdf6ec;
}
.head-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ver-open {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.ver-fields {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 16px;
  margin-bottom: 20px;
}
.ver-fields .field {
  margin-bottom: 0;
}
.ver-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.veritable .dim,
.ver-fields input:disabled {
  background: var(--panel-2);
  color: var(--muted-2);
  cursor: not-allowed;
}
.veritable .tinfo {
  color: var(--text);
}
.veritable thead th {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}

/* Verifikationstabell (Fortnox-lik kontering) */
.veritable tfoot td {
  border-bottom: none;
}
.veritable .sum-row td {
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
  background: var(--panel-2);
  padding-top: 10px;
}
.veritable .diff-row td {
  font-weight: 700;
  padding-top: 4px;
}
.veritable .benamning {
  color: var(--muted);
}
.veritable .benamning.bad {
  color: var(--neg);
}
.veritable .kontosaldo {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.balance-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.balance-bar.ok {
  background: var(--brand-050);
  border-color: var(--brand-100);
}
.balance-bar.bad {
  background: #fdedeb;
  border-color: #f5c9c3;
}
.balance-sums {
  font-variant-numeric: tabular-nums;
}
.balance-status {
  font-weight: 800;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar .field {
  margin-bottom: 0;
}
.toolbar input,
.toolbar select {
  min-width: 150px;
}
.spacer {
  flex: 1;
}

/* ---------- Empty & misc ---------- */
.empty {
  color: var(--muted);
  padding: 48px 20px;
  text-align: center;
}
.empty .big {
  font-size: 30px;
  display: block;
  margin-bottom: 8px;
}
.callout {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.callout.ok {
  background: var(--brand-050);
  color: var(--brand-700);
}
.callout.bad {
  background: #fdeded;
  color: var(--neg);
}
.skeleton {
  height: 90px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--panel-2), var(--panel), var(--panel-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-weight: 600;
  z-index: 60;
  max-width: 380px;
  animation: slidein 0.18s ease-out;
}
@keyframes slidein {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}
.toast.ok {
  background: var(--brand);
}
.toast.err {
  background: var(--neg);
}

/* ---------- Responsive sidebar ---------- */
@media (max-width: 860px) {
  .hamburger {
    display: block;
  }
  .company-switch .company-meta,
  .topbar-search,
  .year-pill {
    display: none;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    padding: 20px 16px 60px;
  }
}

/* --- Inloggning ---------------------------------------------------------- */
body.login-mode {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--panel-2);
}
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: 100%;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}
.login-brand {
  font-weight: 800;
  font-size: 22px;
  color: var(--brand-700);
  margin-bottom: 18px;
}
.login-brand span {
  color: var(--text);
}
.login-card h1 {
  margin: 0 0 18px;
  font-size: 20px;
}
.login-card .primary {
  width: 100%;
  margin-top: 8px;
}
.login-msg {
  background: var(--panel-2);
  border-left: 3px solid var(--brand);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 0 16px;
}
.login-err {
  color: var(--neg);
  font-size: 13px;
  margin: 4px 0 0;
}

/* --- Bolagsväljare och roll i topbaren ----------------------------------- */
.company-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-weight: 700;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
  max-width: 190px;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}
.role-chip {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

/* Revisor har endast läsbehörighet – dölj skrivåtgärder. */
body.read-only .primary,
body.read-only .ver-pill.green,
body.read-only .ver-pill.danger,
body.read-only .ver-pill.outline,
body.read-only .pay-btn,
body.read-only .att-drop {
  display: none !important;
}

/* --- Administration: medlemmar och integritet ---------------------------- */
.temp-pw {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--brand-100);
  background: var(--brand-050);
  border-radius: 10px;
}
.temp-pw p {
  margin: 8px 0 4px;
  font-size: 13px;
}
.temp-pw code {
  display: block;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  user-select: all;
  word-break: break-all;
}
.role-sel {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
.preview-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border-left: 3px solid var(--border-strong);
  background: var(--panel-2);
}
.preview-box.ok {
  border-left-color: var(--brand);
}
.preview-box.warn {
  border-left-color: var(--warn);
}
.preview-box p {
  margin: 6px 0 0;
  font-size: 13px;
}
.legal-note {
  border-left: 3px solid var(--warn);
}
.legal-note p {
  font-size: 13px;
}
.chip-warn {
  color: #a5641a;
  background: #fdf6ec;
  border-color: #edc98f;
}

.login-alt {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
}
.login-card .muted {
  font-size: 13px;
  margin: 0 0 16px;
}
.login-card .hint {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 12px;
}

.pdf-btn {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--brand-700);
  cursor: pointer;
  margin-right: 8px;
}
.pdf-btn:hover:not(:disabled) {
  background: var(--brand-050);
  border-color: var(--brand);
}

/* --- Val av dröjsmålsränta ----------------------------------------------- */
.choice-group {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--panel);
  transition: border-color 0.12s, background 0.12s;
}
.choice:hover {
  border-color: var(--border-strong);
}
.choice.selected {
  border-color: var(--brand);
  background: var(--brand-050);
}
.choice input[type="radio"] {
  width: auto;
  margin: 3px 0 0;
  accent-color: var(--brand);
  flex: 0 0 auto;
}
.choice-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.choice-desc {
  font-size: 12.5px;
  color: var(--muted);
}
.rate-preview {
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--panel-2);
  border-left: 3px solid var(--brand);
}
.rate-badge {
  font-size: 20px;
  font-weight: 800;
  color: var(--brand-700);
}
.rate-example {
  margin: 6px 0 0;
  font-size: 13px;
}
.rate-text {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.field .hint {
  display: block;
  margin-top: 4px;
}

.login-wide {
  width: min(460px, 100%);
}
.login-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--muted-2);
  font-size: 12px;
}
.login-sep::before,
.login-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.report-pdf {
  margin-right: 0;
}
.ver-tool.active {
  cursor: pointer;
  opacity: 1;
  color: var(--brand-700);
}
.ver-tool.active:hover {
  background: var(--brand-050);
}

/* --- Fakturalistor (Fortnox-lik layout) ---------------------------------- */
.list-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.list-head h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.list-search {
  flex: 1 1 260px;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 12px;
}
.list-search:focus-within {
  border-color: var(--brand);
}
.list-search input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  font: inherit;
  color: var(--text);
  outline: none;
}
.create-btn {
  margin-left: auto;
  background: #f5a623;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: 999px;
  white-space: nowrap;
}
.create-btn:hover {
  background: #e0951b;
  text-decoration: none;
}
.list-print {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.list-print button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 2px;
}
.list-print button:hover:not(:disabled) {
  color: var(--brand-700);
  text-decoration: underline;
}

.list-tabs-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.list-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* Statusflik med färgmarkering i vänsterkanten, som i förlagan. */
.ltab {
  position: relative;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  padding: 8px 16px 8px 20px;
  border-radius: 4px;
  cursor: pointer;
}
.ltab::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  border-radius: 4px 0 0 4px;
}
.ltab.open::before {
  background: repeating-linear-gradient(
    45deg, #f4a9a0, #f4a9a0 3px, #fff 3px, #fff 6px
  );
}
.ltab.overdue::before {
  background: #f08475;
}
.ltab.paid::before {
  background: #a5d9b5;
}
.ltab:hover {
  border-color: var(--muted-2);
}
.ltab.active {
  border-color: var(--brand);
  background: var(--brand-050);
  color: var(--brand-700);
  font-weight: 600;
}

.list-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 12.5px;
}
.list-pager select {
  width: auto;
  padding: 5px 8px;
  font-size: 12.5px;
}
.pg {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  border-radius: 4px;
  padding: 4px 9px;
  cursor: pointer;
  color: var(--text);
}
.pg:disabled {
  opacity: 0.35;
  cursor: default;
}
.pg-now {
  font-weight: 600;
  padding: 0 4px;
}

.list-card {
  overflow: hidden;
}
.table-scroll {
  overflow-x: auto;
}
.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.list-table th {
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-2);
  padding: 10px 10px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.list-table th.num {
  text-align: right;
}
/* Sorterad kolumn framhävs, som FAKTNR i förlagan. */
.list-table th.sorted {
  background: var(--border-strong);
  color: var(--text);
}
.list-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.list-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.list-table th.chk,
.list-table td.chk {
  width: 34px;
  padding-left: 12px;
  cursor: default;
}
.list-table input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.faktnr {
  font-weight: 700;
}

/* Radfärg efter status – hela raden, som i förlagan. */
.row-paid {
  background: #e8f5ec;
}
.row-overdue {
  background: #fdeae7;
}
.row-open {
  background: var(--panel);
}
.list-table tbody tr:hover {
  filter: brightness(0.97);
}
@media (prefers-color-scheme: dark) {
  .row-paid {
    background: #16281f;
  }
  .row-overdue {
    background: #2b1a18;
  }
}
.row-tools {
  white-space: nowrap;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sel-count {
  color: var(--muted);
  font-size: 13px;
}
.list-actions .primary {
  margin-left: auto;
}

/* --- Skapa faktura (dokumentvy) ------------------------------------------ */
.doc-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.doc-head h1 {
  margin: 0;
  font-size: 19px;
  white-space: nowrap;
}
.doc-star {
  color: var(--muted-2);
}
.doc-ver {
  font-size: 12.5px;
  color: var(--muted);
  padding-left: 18px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.doc-ver strong {
  color: var(--text);
}
.doc-primary {
  margin-left: auto;
  background: #2b3a31;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.doc-primary:hover:not(:disabled) {
  background: #1d2a22;
}
.doc-list {
  background: #f5c518;
  color: #17251d;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  white-space: nowrap;
}
.doc-list:hover {
  background: #e4b70f;
  text-decoration: none;
}

.doc-tools {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.doc-tool {
  border: none;
  background: transparent;
  color: var(--muted-2);
  font-size: 12.5px;
  cursor: not-allowed;
  padding: 2px;
}

.doc-card {
  padding: 20px;
}
.doc-fields,
.doc-extras {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
}
.doc-fields .field,
.doc-extras .field {
  flex: 1 1 150px;
  min-width: 140px;
  margin: 0;
}
.doc-extras {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.doc-extras .field {
  flex: 0 0 170px;
}
.field.ro input {
  background: var(--panel-2);
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sökbar motpartsväljare */
.party-field {
  position: relative;
  flex: 2 1 280px;
}
.pp-panel {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  min-width: 520px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
}
.pp-head,
.pp-row {
  display: grid;
  grid-template-columns: 110px 1fr 150px 120px;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
}
.pp-head {
  position: sticky;
  top: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.pp-new {
  margin: 0;
  padding: 6px 12px;
  font-size: 11px;
  border: 2px solid #e07b39;
}
.pp-row {
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.pp-row:hover {
  background: var(--brand-050);
}
.pp-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

/* Konteringsrutnät */
.doc-rows {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.doc-rows th {
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-2);
  padding: 9px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.doc-rows th.num,
.doc-rows td.num {
  text-align: right;
}
.doc-rows td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.doc-rows td.num {
  font-variant-numeric: tabular-nums;
}
.doc-rows input,
.doc-rows select {
  margin: 0;
  padding: 6px 8px;
  font-size: 13px;
}
.doc-rows .r-amount {
  text-align: right;
  max-width: 130px;
}
.doc-rows .r-acct {
  min-width: 150px;
}
.r-del {
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
}
.r-del:hover {
  opacity: 1;
}
/* Automatiskt genererade motkonton – syns men går inte att ändra. */
.auto-row td {
  background: var(--panel-2);
}
.sum-row td,
.diff-row td {
  font-weight: 700;
  border-bottom: none;
  padding-top: 10px;
}
.diff-row td {
  color: var(--muted);
  font-weight: 600;
}
.doc-rowtools {
  margin-top: 12px;
}

/* --- Dokumentvy: finjustering mot förlagan -------------------------------- */
.doc-head {
  position: relative;
  align-items: center;
  gap: 0;
  padding: 0 0 16px;
}
/* Grön accent ovanför rubriken, som i förlagan. */
.doc-head::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 0;
  width: 168px;
  height: 4px;
  background: var(--brand);
}
.doc-head h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding-right: 26px;
}
.doc-head h1 #docNo {
  font-weight: 800;
}
.doc-star {
  color: var(--muted-2);
  font-weight: 400;
}
.doc-ver {
  padding-left: 26px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}
.doc-ver #verPreview {
  color: var(--text);
  font-weight: 600;
}
.doc-primary,
.doc-list {
  font-size: 12.5px;
  padding: 9px 18px;
}
.doc-list {
  margin-left: 10px;
}

/* Verktygsband */
.doc-toolbar {
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px 8px;
  margin-bottom: 20px;
}
.doc-tools {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}
.doc-tools.right {
  justify-content: flex-end;
  margin-top: 4px;
}
.doc-tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted-2);
}
.dt-ico {
  font-size: 13px;
  opacity: 0.8;
}

/* Dokumentkroppen är flat – förlagan har inget kort med skugga. */
.doc-body {
  background: var(--panel);
}
.doc-fields {
  gap: 16px;
  margin-bottom: 22px;
}
.doc-fields label,
.doc-extras label {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 5px;
}
.doc-fields input,
.doc-fields select,
.doc-extras input {
  border-radius: 3px;
  border-color: var(--border-strong);
  padding: 8px 10px;
}
.field.w-md {
  flex: 0 0 165px;
  min-width: 165px;
}
.field.w-sm {
  flex: 0 0 145px;
  min-width: 145px;
}
.field.strong input {
  font-weight: 700;
  color: var(--text);
}
/* Kalenderikon i datumfälten */
.has-cal {
  position: relative;
}
.has-cal::after {
  content: "🗓";
  position: absolute;
  right: 10px;
  bottom: 9px;
  font-size: 12px;
  opacity: 0.45;
  pointer-events: none;
}
.field-chev {
  position: absolute;
  right: 10px;
  bottom: 9px;
  color: var(--muted-2);
  font-size: 14px;
  pointer-events: none;
}

/* Väljarpanelen: mörka feta rubriker som i förlagan */
.pp-head {
  text-transform: none;
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-strong);
}
.pp-new {
  justify-self: end;
  border-radius: 4px;
  text-transform: uppercase;
}
.pp-row {
  padding: 11px 16px;
}

/* Radrutnätet: luftigare rader, ljusa linjer */
.doc-rows th {
  background: transparent;
  border-bottom: 1px solid var(--border-strong);
  color: var(--muted);
  padding: 8px;
}
.doc-rows td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
.doc-rows tbody tr td {
  height: 44px;
}
.doc-rows th.icons,
.doc-rows td.icons {
  width: 96px;
  white-space: nowrap;
  text-align: right;
}
.r-ico {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.45;
  padding: 2px 4px;
}
.r-ico:disabled {
  cursor: default;
  opacity: 0.22;
}
.r-ico:not(:disabled):hover {
  opacity: 1;
}
.sum-row td,
.diff-row td {
  border-bottom: none;
  padding-top: 12px;
}
.sum-row td.num:first-of-type,
.diff-row td.num:first-of-type {
  color: var(--muted);
}

/* Avgifterna centreras i botten, som i förlagan */
.doc-extras {
  justify-content: center;
  gap: 28px;
  margin-top: 28px;
  padding-top: 22px;
}

/* --- Artikelregister ----------------------------------------------------- */
.art-form {
  margin-bottom: 16px;
  padding: 18px 20px;
}
.art-form-head {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}
.art-form-head strong {
  font-size: 14px;
}
.art-close {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
}
.art-close:hover {
  color: var(--text);
}
.art-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}
.art-grid .field {
  margin: 0;
}
.art-name {
  flex: 1 1 240px;
  min-width: 200px;
}

/* --- Artikelväljare på fakturaraden -------------------------------------- */
.doc-rows th.art-col,
.doc-rows td.art-cell {
  width: 92px;
  white-space: nowrap;
}
.art-cell {
  position: relative;
}
/* Det stora, tydliga plusset. */
.art-pick {
  width: 26px;
  height: 26px;
  border: 1px solid var(--brand);
  background: var(--brand-050);
  color: var(--brand-700);
  border-radius: 4px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.art-pick:hover {
  background: var(--brand);
  color: #fff;
}
.art-tag {
  margin-left: 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}
.art-panel {
  position: absolute;
  z-index: 50;
  top: 34px;
  left: 0;
  width: 420px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
}
.ap-search {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.ap-search input {
  margin: 0;
  padding: 7px 10px;
  font-size: 13px;
}
.ap-list {
  max-height: 260px;
  overflow-y: auto;
}
.ap-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.ap-row:hover {
  background: var(--brand-050);
}
.ap-no {
  font-weight: 700;
}
.ap-price {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- Registermeny i topbaren --------------------------------------------- */
.reg-menu {
  position: relative;
}
.reg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.reg-btn:hover,
.reg-btn[aria-expanded="true"] {
  border-color: var(--brand);
  background: var(--brand-050);
  color: var(--brand-700);
}
.reg-chev {
  font-size: 13px;
  line-height: 1;
}
.reg-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  min-width: 220px;
  padding: 8px 0;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
.reg-group + .reg-group {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 6px;
}
.reg-group-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-2);
  padding: 6px 16px 4px;
}
.reg-item {
  display: block;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--text);
}
.reg-item:hover {
  background: var(--brand-050);
  color: var(--brand-700);
  text-decoration: none;
}

/* --- Kontoplan: aktiveringsreglage --------------------------------------- */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  vertical-align: middle;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  position: absolute;
}
.slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + .slider {
  background: var(--brand);
}
.switch input:checked + .slider::before {
  transform: translateX(17px);
}
.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px var(--brand-050);
}
/* Inaktivt konto tonas ned, men går fortfarande att läsa. */
.acct-off td:not(:nth-child(5)) {
  opacity: 0.5;
}

/* --- EAN-fält i artikelregistret ----------------------------------------- */
.ean-cell {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12.5px;
}
.ean-hint {
  min-height: 15px;
}
.ean-hint.ok {
  color: var(--brand-700);
}
.ean-hint.bad {
  color: var(--neg);
}
#aEan {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
#aEan.ok {
  border-color: var(--brand);
}
#aEan.bad {
  border-color: var(--neg);
}

/* --- Bankimport och matchning -------------------------------------------- */
.bank-sug {
  margin-top: 4px;
  font-size: 12.5px;
}
.bank-reason {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}
.import-result {
  margin-bottom: 14px;
  padding: 14px 18px;
  border-left: 3px solid var(--brand);
}
.import-result p {
  margin: 6px 0 0;
  font-size: 13px;
}
.bank-help {
  margin-top: 16px;
  padding: 16px 20px;
  max-width: 820px;
}
.bank-help p {
  margin: 8px 0 0;
  font-size: 13px;
}
.list-table td .pos {
  color: var(--pos);
  font-weight: 600;
}
.list-table td .neg {
  color: var(--neg);
  font-weight: 600;
}
.bank-match {
  padding: 5px 12px;
  font-size: 12px;
}

/* --- Kreditfakturor ------------------------------------------------------ */
.ltab.credit::before {
  background: #b9a4d8;
}
.row-credit {
  background: #f4f0fa;
}
.row-credited {
  background: var(--panel-2);
}
@media (prefers-color-scheme: dark) {
  .row-credit {
    background: #241f2e;
  }
}
.row-credit td,
.row-credited td {
  color: var(--muted);
}
.row-credit .faktnr {
  color: #6b4fa0;
}
.credit-btn {
  color: #6b4fa0;
}
.credit-btn:hover:not(:disabled) {
  background: #f4f0fa;
  border-color: #b9a4d8;
}

/* ---------- Modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(23, 37, 29, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadein 0.12s ease-out;
}
@keyframes fadein {
  from {
    opacity: 0;
  }
}
.dialog {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.dialog-x {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dialog-x:hover {
  background: var(--panel-2);
  color: var(--text);
}
.dialog-body {
  padding: 18px 20px 20px;
  overflow: auto;
}
.dialog-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.dialog-field {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dialog-field input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
}
.credit-table input[type="number"] {
  width: 82px;
  text-align: right;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
}
.credit-sum {
  display: flex;
  justify-content: flex-end;
  gap: 32px;
  padding: 14px 2px 0;
}
.credit-sum div {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.credit-sum .muted {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.credit-sum strong {
  font-size: 17px;
}
.dialog-error {
  margin: 12px 0 0;
  color: var(--neg);
  font-size: 13px;
  font-weight: 600;
}
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.dialog-actions .ghost-btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.dialog-actions .ghost-btn:hover {
  background: var(--panel-2);
}
.dialog-actions .create-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.dialog-actions .create-btn:disabled {
  background: var(--border-strong);
  cursor: not-allowed;
}
@media (prefers-color-scheme: dark) {
  .overlay {
    background: rgba(0, 0, 0, 0.6);
  }
}

/* ---------- Regler för återkommande betalningar ---------- */
.rule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px 14px;
}
.rule-grid .dialog-field {
  display: flex;
  margin-bottom: 0;
}
.rule-grid .dialog-field.wide {
  grid-column: span 3;
}
.rule-grid select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
}
.rule-grid .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted-2);
  font-size: 11px;
}
#rPreview {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  max-width: 460px;
}
@media (max-width: 720px) {
  .rule-grid {
    grid-template-columns: 1fr;
  }
  .rule-grid .dialog-field.wide {
    grid-column: span 1;
  }
}
.rule-active {
  flex-direction: column;
  gap: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
}
.rule-active input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: -1px;
}

/* ---------- Avtalsfakturor ---------- */
.due-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 12px;
  border-left: 4px solid var(--warn);
}
.due-bar button {
  margin-left: auto;
}
.due-bar.err {
  border-left-color: var(--neg);
  color: var(--neg);
  font-size: 13px;
  display: block;
}
.line-add {
  margin: 8px 0 4px;
}
.credit-table .lDesc {
  width: 100%;
  min-width: 150px;
}
.credit-table select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
}
.credit-table input:not([type="number"]):not([type="checkbox"]) {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
}
.badge.red {
  background: #fdecec;
  border-color: #f3c3c3;
  color: #a63232;
}
@media (prefers-color-scheme: dark) {
  .badge.red {
    background: #3a2222;
    border-color: #5c3434;
    color: #f0a5a5;
  }
}

/* ---------- Makulerade fakturor ---------- */
.ltab.void::before {
  background: var(--muted-2);
}
.row-void {
  background: var(--panel-2);
}
.row-void td {
  color: var(--muted-2);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}
/* Knapparna ska gå att läsa och klicka även på en överstruken rad. */
.row-void .row-tools,
.row-void .row-tools * {
  text-decoration: none;
  color: var(--muted);
}
.void-btn {
  color: #a63232;
}
.void-btn:hover:not(:disabled) {
  background: #fdecec;
  border-color: #f3c3c3;
}

/* ---------- E-postdialogen ---------- */
.mail-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
}
.mail-body textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--panel);
  resize: vertical;
}
.bulk-status {
  margin-left: 12px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Verifieringssteget ---------- */
.login-hint { color: var(--muted); font-size: 14px; line-height: 1.6; }
.btn-link {
  display: inline-block;
  margin-top: 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: 999px;
  text-decoration: none;
}
.btn-link:hover { background: var(--brand-600); text-decoration: none; }

.gate-card { max-width: 460px; }
.gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.gate-actions .primary,
.gate-actions .ghost-btn {
  font: inherit;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 999px;
  cursor: pointer;
}
.gate-actions .primary {
  border: none;
  background: var(--brand);
  color: #fff;
}
.gate-actions .primary:hover:not(:disabled) { background: var(--brand-600); }
.gate-actions .primary:disabled { background: var(--border-strong); cursor: default; }
.gate-actions .ghost-btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
}
.gate-actions .ghost-btn:hover { background: var(--panel-2); }
.gate-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.gate-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.gate-form input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
}
.gate-form input:focus { outline: none; border-color: var(--brand); }
.gate-form .primary {
  border: none;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 999px;
  cursor: pointer;
  margin-top: 4px;
}
.gate-status {
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  min-height: 1em;
}
.link-btn {
  margin-top: 18px;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { color: var(--text); }
