/* ---- Tokens ---- */
:root {
  --pine: #2C4A3E;
  --pine-dark: #1D3229;
  --paper: #FAF6EC;
  --paper-raised: #FFFFFF;
  --ink: #2A2A28;
  --ink-soft: #6B675E;
  --lingon: #A63D40;
  --gold: #C9A24B;
  --line: #E4DFD1;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(30, 30, 20, 0.06), 0 4px 14px rgba(30, 30, 20, 0.05);
  --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--pine); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--pine-dark);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

/* ---- Top bar ---- */
.topbar {
  background: var(--pine);
  color: var(--paper);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar .brand {
  font-family: var(--font-display);
  font-size: 20px;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}

.topbar nav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.topbar nav a {
  color: #E7E2D2;
  text-decoration: none;
  font-size: 14px;
}

.topbar nav a:hover, .topbar nav a.active { color: #fff; text-decoration: underline; }

.topbar .user-pill {
  background: rgba(255,255,255,0.12);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
}

/* ---- Layout ---- */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.container.narrow { max-width: 460px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.page-header p { color: var(--ink-soft); margin: 4px 0 0; }

/* ---- Cards ---- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.cottage-card h3 { margin-bottom: 4px; }
.cottage-card .meta { color: var(--ink-soft); font-size: 14px; margin-bottom: 12px; }
.cottage-card .photo {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 12px;
  background: var(--line);
}

/* ---- Forms ---- */
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 5px; color: var(--ink); }
label:first-child { margin-top: 0; }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
}

textarea { resize: vertical; min-height: 70px; }

.field-hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 6px;
  border: none;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
}

.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-dark); }
.btn-approve { background: #3E7A4F; color: #fff; }
.btn-reject { background: var(--lingon); color: #fff; }
.btn-secondary { background: #fff; color: var(--pine); border: 1px solid var(--line); }
.btn-small { padding: 6px 12px; font-size: 13px; }

form.inline { display: inline; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
}
.badge-pending { background: #F5E9D0; color: #8A6A1D; }
.badge-approved { background: #DEEEDF; color: #2C6B39; }
.badge-rejected { background: #F5DEDD; color: var(--lingon); }
.badge-cancelled { background: #EAE7DD; color: var(--ink-soft); }

/* ---- Table ---- */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- Flash messages ---- */
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; font-size: 14.5px; }
.flash-success { background: #DEEEDF; color: #2C6B39; }
.flash-error { background: #F5DEDD; color: var(--lingon); }
.flash-info { background: #EDF1F3; color: #3A5A6B; }

/* ---- Misc ---- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
}

.divider-wave {
  height: 14px;
  background: linear-gradient(135deg, var(--gold) 0 2px, transparent 2px 100%) 0 0/14px 14px;
  opacity: 0.5;
  margin: 28px 0;
}

.stat {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--pine);
}
.stat-label { color: var(--ink-soft); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- Calendar ---- */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  max-width: 340px;
}

.calendar-month-label {
  margin: 0;
  font-size: 16px;
  text-align: center;
  flex: 1;
}

.calendar-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 10px;
  max-width: 340px;
}

.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -1px;
}

.legend-approved { background: var(--lingon); }
.legend-pending-mine { background: var(--gold); }
.legend-pending-other { background: #D9D3C2; border: 1px dashed var(--ink-soft); }
.legend-past { background: #DAD5C7; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  margin: 0 0 8px;
  max-width: 340px;
}

.calendar-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding-bottom: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #F3EFE3;
  font-size: 12.5px;
  color: var(--ink);
  cursor: default;
}

.calendar-day-empty { background: transparent; }

.calendar-day-today {
  box-shadow: inset 0 0 0 2px var(--pine);
  font-weight: 700;
}

.calendar-day-approved {
  background: var(--lingon);
  color: #fff;
  font-weight: 600;
}

.calendar-day-pending-mine {
  background: #FBEFD2;
  color: #8A6A1D;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--gold);
}

.calendar-day-pending-other {
  background: #EAE7DD;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--ink-soft);
  border-style: dashed;
}

.calendar-day-past {
  background: #DAD5C7;
  color: #9C9787;
}

@media (max-width: 600px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  th, td { font-size: 13px; }
  .calendar-grid { gap: 3px; padding: 8px; max-width: 100%; }
  .calendar-day { font-size: 11.5px; border-radius: 4px; }
  .calendar-month-label { font-size: 15px; }
  .calendar-nav, .calendar-legend { max-width: 100%; }
}

/* ===================================================================
   Bokföring: tillägg ovanpå stugbokningens stilmall
   =================================================================== */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.unit-switch { margin: 0 auto 0 18px; }
.unit-switch select {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  font-size: 14px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
}
.unit-switch select option { color: var(--ink); }

table td.num, table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
code.secret { font-size: 17px; letter-spacing: 0.08em; background: var(--paper); padding: 6px 10px; border-radius: 6px; display: inline-block; }

.badge-naring { background: #DEEEDF; color: #2C6B39; }
.badge-privat { background: #EDF1F3; color: #3A5A6B; }
.badge-read   { background: #EAE7DD; color: var(--ink-soft); }
.badge-write  { background: #F5E9D0; color: #8A6A1D; }
.badge-off    { background: #F5DEDD; color: var(--lingon); }

.unit-card { border-left: 4px solid var(--pine); }
.unit-card.privat { border-left-color: #3A5A6B; }
.unit-card.current { box-shadow: 0 0 0 2px var(--gold), var(--shadow); }
.unit-card .meta { color: var(--ink-soft); font-size: 14px; margin: 4px 0 12px; }

.konto-group td { background: var(--paper); font-weight: 600; color: var(--pine-dark); }

.table-scroll { overflow-x: auto; }
table select.inline-select { width: auto; margin: 0; padding: 4px 8px; font-size: 13px; }
form.inline { display: inline; }

.form-row { display: grid; grid-template-columns: 110px 1fr 170px; gap: 10px; align-items: end; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

details.edit-inline { display: inline-block; margin-left: 6px; }
details.edit-inline summary { cursor: pointer; font-size: 12.5px; color: var(--ink-soft); list-style: none; }
details.edit-inline summary::-webkit-details-marker { display: none; }
details.edit-inline summary::before { content: "✎ "; }
details.edit-inline[open] form { display: flex; gap: 6px; margin-top: 6px; min-width: 240px; }
details.edit-inline input { margin: 0; padding: 5px 8px; font-size: 14px; }

/* ---- Verifikat ---- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filter-bar > div { flex: 1 1 160px; }
.filter-bar > div:last-child { flex: 0 0 auto; }
.filter-bar label { margin-top: 0; }
.fy-picker select { width: auto; margin: 0; padding: 7px 10px; font-size: 14px; }

.ver-head { display: grid; grid-template-columns: 170px 220px 1fr; gap: 12px; }
.ver-head label { margin-top: 0; }
@media (max-width: 760px) { .ver-head { grid-template-columns: 1fr 1fr; } .ver-text { grid-column: 1 / -1; } }

details.quick summary { cursor: pointer; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }

table.ver-rows td { padding: 4px 4px; vertical-align: middle; }
table.ver-rows select, table.ver-rows input { margin: 0; padding: 6px 8px; font-size: 14px; }
table.ver-rows .f-amt { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
table.ver-rows .f-kst { min-width: 70px; }
table.ver-rows .f-text { min-width: 140px; }
tr.sum-row td { font-weight: 600; border-top: 2px solid var(--line); background: var(--paper); }
.ok { color: #2C6B39; font-weight: 600; }
.bad { color: var(--lingon); font-weight: 600; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.ver-meta { display: flex; flex-wrap: wrap; gap: 24px; }
.ver-meta > div { flex: 1 1 120px; }

.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.attachment { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--paper); word-break: break-word; }
.attachment-preview { display: flex; align-items: center; justify-content: center; height: 150px; background: #fff; border-radius: 6px; margin-bottom: 8px; overflow: hidden; text-decoration: none; }
.attachment-preview img { max-width: 100%; max-height: 150px; object-fit: contain; }
.attachment-icon { font-family: var(--font-display); font-size: 26px; color: var(--lingon); border: 2px solid var(--lingon); border-radius: 6px; padding: 10px 14px; }

table.clickable a.row-link { color: inherit; text-decoration: none; }
table.clickable tbody tr:hover { background: var(--paper); }

/* ---- Rapporter ---- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--ink-soft); border-bottom: 3px solid transparent; font-size: 15px; }
.tabs a.active { color: var(--pine-dark); border-bottom-color: var(--gold); font-weight: 600; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
table.report { font-size: 14px; }
table.report td { padding: 5px 8px; }
table.report tr.r-group td { background: var(--paper); font-weight: 600; color: var(--pine-dark); }
table.report tr.r-big td { font-family: var(--font-display); font-size: 15px; padding-top: 14px; }
table.report tr.r-sum td { font-weight: 600; border-bottom: 1px solid var(--ink-soft); }
table.report tr.r-total td { font-weight: 700; border-top: 2px solid var(--pine-dark); border-bottom: 2px solid var(--pine-dark); }
table.report tr.r-ver td { background: var(--paper); font-weight: 600; border-top: 1px solid var(--line); }
table.report tr.r-warn td { color: var(--lingon); font-weight: 700; }
table.report td.neg { color: var(--lingon); }
.report-note { color: var(--ink-soft); font-size: 13px; margin: 10px 0 0; }

@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body, html { background: #fff; }
  .container { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
  table.report { font-size: 11px; }
  table.report td.neg { color: #000; }
  a { color: inherit; text-decoration: none; }
}

/* Verifikatrader staplas på smala skärmar */
@media (max-width: 640px) {
  table.ver-rows thead { display: none; }
  table.ver-rows, table.ver-rows tbody, table.ver-rows tfoot { display: block; }
  table.ver-rows tr { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.ver-rows td { display: block; padding: 0; border: none; }
  table.ver-rows td:first-child { grid-column: 1 / -1; }
  table.ver-rows td:has(.f-kst) { grid-column: 1 / -1; }
  table.ver-rows td:has(.f-text) { grid-column: 1 / 3; }
  table.ver-rows .f-amt, table.ver-rows .f-text, table.ver-rows select { width: 100%; }
  table.ver-rows tr.sum-row { grid-template-columns: 1fr 1fr; }
  table.ver-rows tr.sum-row td { text-align: left; }
  table.ver-rows tr.sum-row td:first-child, table.ver-rows tr.sum-row td:last-child { grid-column: 1 / -1; }
}
.link-btn { background: none; border: none; padding: 0; margin-left: 6px; color: var(--pine); text-decoration: underline; font-size: 12.5px; cursor: pointer; font-weight: 400; }
h4 { margin: 0 0 6px; font-family: var(--font-display); color: var(--pine-dark); }
ul.doc-list { margin: 0; padding-left: 18px; }
ul.doc-list li { margin: 4px 0; }
.quick-grid > div { min-width: 0; }
.quick-grid input, .quick-grid select { width: 100%; }
@media (max-width: 520px) {
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .quick-grid > div[style*="span"] { grid-column: 1 / -1 !important; }
}
