/* LTE Ekonomi — designspråk: skandinavisk redaktionell, lugn, varm off-white,
   distinkta typsnitt, koppar-accent. Optimerad för iPad-touch men fungerar lika bra på desktop. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Palett */
  --bg:        #f4f1ec;          /* varm off-white */
  --bg-card:  #ffffff;
  --bg-card-sub: #faf7f2;
  --ink:      #1a1814;           /* nästan svart, varmton */
  --ink-soft: #5a554d;
  --ink-faint:#8b857a;
  --line:     #e6e0d6;
  --line-soft:#efe9de;
  --accent:   #b85c2c;           /* koppar */
  --accent-soft: #f3e6dc;
  --accent-deep: #8d4720;
  --ok:       #4a6b3a;
  --ok-soft:  #e8eee0;
  --warn:     #a36818;
  --warn-soft:#f5e9d4;
  --neutral:  #5f6873;
  --neutral-soft:#e9ecef;
  --danger:   #a23a2e;
  --danger-soft:#f3dfdb;

  --r-sm:  4px;
  --r:     8px;
  --r-lg:  14px;
  --shadow-1: 0 1px 2px rgba(26,24,20,.04), 0 1px 3px rgba(26,24,20,.06);
  --shadow-2: 0 8px 24px rgba(26,24,20,.10), 0 2px 6px rgba(26,24,20,.06);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter Tight', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: calc(18px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 14px; }
.mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.02em;
  border-radius: var(--r-sm);
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  line-height: 1;
  letter-spacing: -0.01em;
}
.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
  font-size: 13px;
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-card-sub);
  border: 1px solid var(--line-soft);
}

/* === Knappar === */
.btn-primary, .btn-ghost, .btn-icon {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  border-radius: var(--r);
  border: 1px solid transparent;
  cursor: pointer;
  padding: 10px 18px;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { background: #2d2922; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg-card-sub); color: var(--ink); }
.btn-icon {
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 12px;
  min-width: 40px;
  font-size: 16px;
}
.btn-icon:hover { background: var(--bg-card-sub); }
.btn-block { width: 100%; }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #872d24; }

/* === Layout === */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px;
}

/* === KPIs === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.kpi-primary .kpi-label, .kpi-primary .kpi-hint { color: rgba(244,241,236,0.65); }
.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  font-weight: 500;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-hint {
  font-size: 12px;
  color: var(--ink-faint);
}

/* === VO-strip === */
.vo-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.vo-pill {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
}
.vo-pill-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 500;
}
.vo-pill-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* === Filter === */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.filter-bar input[type="search"] {
  flex: 1 1 260px;
  min-width: 200px;
}
.filter-selects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.result-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-faint);
  padding: 0 8px;
}

input, select, textarea {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 14px;
  min-height: 42px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="search"] {
  background-image: none;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a554d' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* === Order-lista === */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.order-row {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .05s;
}
.order-row:hover { border-color: var(--ink-faint); background: var(--bg-card-sub); }
.order-row:active { transform: scale(0.998); }
.order-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.order-titel {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.order-titel .pos {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 400;
  letter-spacing: 0;
}
.order-besk {
  font-size: 14px;
  color: var(--ink-soft);
}
.order-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.tag {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-card-sub);
  color: var(--ink-soft);
  border: 1px solid var(--line-soft);
}
.tag-kund { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; }
.order-belopp {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  text-align: right;
  white-space: nowrap;
}
.order-belopp-label {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.order-status-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Status-pills */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-vantar     { background: var(--warn-soft);    color: var(--warn); }
.status-pagar      { background: var(--accent-soft);  color: var(--accent-deep); }
.status-fakturerad { background: var(--ok-soft);      color: var(--ok); }
.status-delfakturerad, .status-delfaktura { background: var(--neutral-soft); color: var(--neutral); }
.status-annulerad  { background: var(--danger-soft);  color: var(--danger); }

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,24,20,0.4);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
  animation: slideUp 0.22s cubic-bezier(0.3, 0.7, 0.4, 1);
}
@keyframes slideUp { from { transform: translateY(20px); } to { transform: translateY(0); } }

@media (min-width: 768px) {
  .modal { align-items: center; padding: 24px; }
  .modal-panel { border-radius: var(--r-lg); max-height: 88vh; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.modal-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.modal-info {
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg-card-sub);
  padding: 10px 14px;
  border-radius: var(--r);
  border-left: 3px solid var(--accent);
  margin: 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.req { color: var(--accent); }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
}

fieldset.status-choice {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 16px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
fieldset.status-choice legend {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 0 6px;
}
.radio {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
  font-size: 15px !important;
  color: var(--ink) !important;
}
.radio input { min-height: auto; width: auto; }

/* === Detalj-modal === */
.detalj-rad {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.detalj-rad:last-child { border-bottom: 0; }
.detalj-label { color: var(--ink-faint); font-weight: 500; }
.detalj-value { font-variant-numeric: tabular-nums; }
.detalj-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  z-index: 200;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.toast.error { background: var(--danger); }

/* === Login === */
.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 380px; text-align: center; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-1);
}
.login-brand { margin-bottom: 24px; }
.login-mark {
  width: 56px; height: 56px;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  border-radius: var(--r);
  margin: 0 auto 16px;
}
.login-brand h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 0;
}
.login-sub {
  font-size: 13px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 4px 0 0;
}
#login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  margin-top: 24px;
}
#login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.login-fel {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px 14px;
  border-radius: var(--r);
}
.login-foot {
  margin-top: 18px;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}

/* === Hjälp === */
.muted { color: var(--ink-faint); text-align: center; padding: 40px 20px; }
[hidden] { display: none !important; }

/* === iPad/Mobile === */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar { padding: 14px 18px; }
  main { padding: 18px; }
  .topbar-actions .btn-ghost { display: none; }
  .user-chip { display: none; }
  .order-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .order-belopp { text-align: left; }
  .order-status-cell { justify-content: flex-start; }
  .filter-selects { width: 100%; }
  .filter-selects select { flex: 1; min-width: 0; }
  .brand-sub { display: none; }
}

@media (max-width: 480px) {
  .topbar { gap: 8px; }
  .brand h1 { font-size: 18px; }
  .btn-primary { padding: 8px 12px; font-size: 13px; }
}
