:root {
  --bg: #f6f2eb;
  --surface: #fffdf9;
  --surface-2: #fbf8f2;
  --line: #ddd6c9;
  --text: #183a67;
  --muted: #667585;
  --green: #758d67;
  --green-soft: #e9efe3;
  --blue-soft: #e7eef7;
  --peach-soft: #f7ebe6;
  --butter-soft: #f4eddc;
  --shadow: 0 12px 32px rgba(18, 31, 45, 0.07);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fbf8f3, #f6f2eb 25%, #f3eee7 100%);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; }
.hidden { display: none !important; }
.wordmark { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: -.04em; font-size: 3rem; line-height: 1; }
.wordmark.small { font-size: 2rem; }
.wordmark.big { font-size: clamp(3rem, 9vw, 4.8rem); }
.card {
  background: rgba(255,253,249,.94);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.desktop-only { display: none; }
.mobile-only { display: block; }
.icon-button {
  width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.72);
  display: grid; place-items: center; padding: 0;
}
.icon-button img { width: 20px; height: 20px; }
.primary-button, .secondary-button {
  border: 0; min-height: 44px; border-radius: 14px; padding: 0 16px; font-weight: 700;
}
.primary-button { background: var(--green); color: white; }
.secondary-button { background: #efebe3; color: #334252; }
.error-box, .flash {
  padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; font-size: .95rem;
}
.error-box { background: #fae6e1; border: 1px solid #f0c1b5; color: #873528; }
.flash { background: #ebf3e4; border: 1px solid #cdddc2; color: #385342; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-shell { width: min(420px, 100%); text-align: center; }
.login-house { width: 150px; margin: 0 auto 16px; }
.tagline { color: var(--green); margin: 8px 0 24px; font-size: 1.25rem; }
.login-card { padding: 20px; text-align: left; }
.login-card label, .dialog-form label { display: grid; gap: 8px; font-weight: 700; margin-bottom: 14px; color: #253649; }
.input-row {
  display: flex; align-items: center; gap: 10px; min-height: 52px; border: 1px solid var(--line); border-radius: 14px; background: white; padding: 0 14px;
}
.input-row img { width: 20px; height: 20px; }
.input-row input, textarea, select { width: 100%; border: 0; outline: 0; background: transparent; color: #243547; }
textarea { resize: vertical; min-height: 84px; }
.ghost-icon { border: 0; background: transparent; padding: 0; }
.remember-line { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; }
.remember-line input { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: #d9d5cd; position: relative; margin: 0; }
.remember-line input::after { content: ""; position: absolute; width: 22px; height: 22px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgba(0,0,0,.15); transition: .18s ease; }
.remember-line input:checked { background: var(--green); }
.remember-line input:checked::after { left: 23px; }
.big-button { width: 100%; }

/* layout */
.site-shell { min-height: 100vh; }
.main-shell { max-width: 1220px; margin: 0 auto; padding: 0 16px 92px; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 8px; background: linear-gradient(180deg, rgba(246,242,235,.98), rgba(246,242,235,.85)); backdrop-filter: blur(8px);
}
.mobile-brand { text-align: center; flex: 1; }
.mobile-brand .sidebar-tagline { font-size: .82rem; }
.topbar-actions { display: flex; gap: 8px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 10px 2px 14px; }
.page-header h1 { margin: 0 0 6px; font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.04em; }
.page-header p { margin: 0; color: var(--muted); }
.sprig { width: 86px; opacity: .75; }

#app { display: grid; gap: 16px; }
.home-top { display: grid; gap: 16px; }
.home-bottom { display: grid; gap: 16px; }
.panel-card { padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 700; }
.panel-title img { width: 22px; height: 22px; }
.panel-subtle { color: var(--muted); font-size: .92rem; }
.panel-link { color: var(--text); font-size: .95rem; text-decoration: none; font-weight: 600; }
.tone-shopping { background: linear-gradient(180deg, #fcfdf9, var(--surface)); }
.tone-calendar { background: linear-gradient(180deg, #fbfcff, var(--surface)); }
.tone-vera { background: linear-gradient(180deg, #fffdfa, var(--surface)); }
.tone-gustav { background: linear-gradient(180deg, #fffdf9, var(--surface)); }
.tone-plans { background: linear-gradient(180deg, #fcfdfb, var(--surface)); }

.quick-inline { display: flex; gap: 10px; align-items: center; }
.quick-inline input {
  flex: 1; min-width: 0; min-height: 42px; border-radius: 12px; border: 1px solid var(--line); background: white; padding: 0 12px;
}
.small-button { min-height: 42px; padding: 0 14px; border-radius: 12px; }

.shopping-list, .simple-list, .wish-list, .calendar-list { display: grid; gap: 8px; }
.list-row, .wish-row, .plan-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 0; border-top: 1px solid #ece6dd;
}
.shopping-list .list-row:first-child, .wish-list .wish-row:first-child, .simple-list .plan-row:first-child { border-top: 0; }
.checkbox {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid #ccd1c7; background: white; display: grid; place-items: center;
}
.checkbox.done { background: var(--green); border-color: var(--green); color: white; font-size: .9rem; }
.item-main { min-width: 0; }
.item-title { font-weight: 600; color: #23354b; }
.item-note { color: var(--muted); font-size: .9rem; }
.row-actions { display: flex; gap: 8px; }
.mini-button {
  width: 34px; height: 34px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; padding: 0;
}
.mini-button img { width: 16px; height: 16px; }
.done-text .item-title, .done-text .item-note { text-decoration: line-through; opacity: .65; }

.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.pill-select {
  border: 1px solid var(--line); border-radius: 12px; min-height: 40px; padding: 0 12px; background: white;
}
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-label { font-weight: 700; }
.week-grid { overflow-x: auto; border: 1px solid #ece6dd; border-radius: 16px; }
.week-grid table { width: 100%; min-width: 620px; border-collapse: collapse; }
.week-grid th, .week-grid td { border-right: 1px solid #efe9df; border-top: 1px solid #efe9df; padding: 10px 8px; text-align: left; vertical-align: top; }
.week-grid thead th { border-top: 0; font-size: .85rem; color: var(--muted); font-weight: 700; background: #fff; }
.week-grid tbody th { width: 86px; font-size: .9rem; font-weight: 700; background: #fffdf9; }
.week-grid td:last-child, .week-grid th:last-child { border-right: 0; }
.event-chip {
  display: inline-grid; gap: 2px; padding: 8px; border-radius: 12px; font-size: .84rem; margin-bottom: 4px; min-width: 100px;
}
.event-chip.blue { background: #e9f0f7; }
.event-chip.green { background: #ebf3e5; }
.event-chip.peach { background: #f7ebe4; }
.event-chip.terracotta { background: #f3e3de; }
.event-chip strong { font-size: .8rem; }

.wish-row { grid-template-columns: 52px 1fr auto; }
.thumb {
  width: 52px; height: 52px; border-radius: 14px; border: 1px solid #ece6dd; background: #f9f6ef; display: grid; place-items: center; overflow: hidden;
}
.thumb img { width: 44px; height: 44px; object-fit: contain; }
.plan-row { grid-template-columns: 20px 1fr auto; }
.plan-row .leaf { width: 16px; height: 16px; opacity: .9; }
.empty { padding: 18px; border: 1px dashed #d6d1c6; border-radius: 16px; color: var(--muted); text-align: center; }

.detail-layout { display: grid; gap: 16px; }
.detail-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.full-list .list-row, .full-list .wish-row, .full-list .plan-row { padding: 12px 0; }

.more-grid { display: grid; gap: 16px; }
.menu-card {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 16px; width: 100%; border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
}
.menu-card img.icon { width: 22px; height: 22px; }
.menu-card .icon-wrap {
  width: 52px; height: 52px; border-radius: 16px; background: #fff; border: 1px solid #ece6dd; display: grid; place-items: center;
}
.arrow { color: var(--muted); font-size: 1.2rem; }
.mobile-drawer {
  position: fixed; inset: 0; z-index: 45; background: rgba(18,31,45,.28); padding: 16px;
}
.drawer-card { padding: 16px; max-width: 360px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.drawer-nav { display: grid; gap: 8px; }
.drawer-link { width: 100%; text-align: left; border: 1px solid var(--line); background: white; border-radius: 14px; padding: 12px 14px; }
.side-link.active, .drawer-link.active, .bottom-link.active { background: #eef2e8; color: var(--text); }

.modal { border: 0; padding: 0; background: transparent; width: min(520px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(18,31,45,.35); }
.dialog-form { padding: 18px; }
.dialog-head, .dialog-actions, .two-cols { display: grid; gap: 12px; }
.dialog-head { grid-template-columns: 1fr auto; align-items: center; margin-bottom: 8px; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 10px 16px calc(10px + var(--safe-bottom)); background: rgba(255,253,249,.98); border-top: 1px solid var(--line); backdrop-filter: blur(8px);
}
.bottom-link {
  border: 0; background: transparent; border-radius: 14px; color: var(--muted); display: grid; place-items: center; gap: 4px; padding: 6px 4px;
}
.bottom-link img { width: 21px; height: 21px; }
.bottom-link small { font-size: .72rem; }

@media (min-width: 900px) {
  .desktop-only { display: block; }
  .mobile-only { display: none; }
  .site-shell { display: grid; grid-template-columns: 250px 1fr; max-width: 1440px; margin: 0 auto; gap: 24px; padding: 20px; }
  .sidebar {
    position: sticky; top: 20px; align-self: start; min-height: calc(100vh - 40px); background: rgba(255,253,249,.84); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); padding: 24px 18px; display: flex; flex-direction: column; gap: 20px;
  }
  .sidebar-brand { text-align: left; }
  .sidebar-tagline { color: var(--green); margin-top: 8px; font-size: .95rem; }
  .sidebar-house { width: 92px; margin-top: 14px; }
  .side-nav { display: grid; gap: 6px; }
  .side-link {
    border: 0; background: transparent; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; color: #2f3d50; text-align: left;
  }
  .side-link img { width: 20px; height: 20px; }
  .side-link.active { background: #eef2e8; }
  .sidebar-note { margin-top: auto; padding-top: 24px; color: var(--muted); font-size: .92rem; }
  .sidebar-note img { width: 24px; margin-bottom: 8px; }
  .main-shell { max-width: none; padding: 0 0 28px; }
  .topbar { padding: 8px 0 6px; }
  .topbar-spacer { flex: 1; }
  .home-top { grid-template-columns: 1fr 1.65fr; }
  .home-bottom { grid-template-columns: repeat(3, 1fr); }
  .detail-layout.two-col { grid-template-columns: 1.05fr 1fr; align-items: start; }
  .more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav { display: none; }
}


/* Servus-tjänster */
.services-panel {
  background: linear-gradient(180deg, #fbfcff, var(--surface));
}
.services-grid {
  display: grid;
  gap: 10px;
}
.service-link {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  text-decoration: none;
  color: var(--text);
}
.service-link strong {
  display: block;
  color: #23354b;
}
.service-link small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}
.service-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  border: 1px solid #ece6dd;
}
.service-minecraft .service-icon { background: #eef2e8; }
.service-photos .service-icon { background: #e7eef7; }
.service-cloud .service-icon { background: #f7ebe6; }

@media (min-width: 900px) {
  .services-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}


/* Inköpslista med avdelningar */
.shopping-head { align-items: flex-start; }
.shopping-controls { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.shopping-controls label { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .92rem; }
.shopping-table-head, .catalog-table-head {
  display: grid;
  grid-template-columns: 1.25fr 1fr 96px;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #ece6dd;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}
.shopping-row, .catalog-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 96px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #ece6dd;
}
.shopping-product-cell { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.department-cell { color: var(--muted); font-size: .9rem; }
.department-cell.unknown { color: #9a5b42; }
.link-button { display: block; margin-top: 4px; border: 0; background: transparent; color: var(--text); text-decoration: underline; padding: 0; font-weight: 700; }
.catalog-table { display: grid; }
.catalog-row:first-of-type, .shopping-row:first-of-type { border-top: 0; }

@media (max-width: 620px) {
  .shopping-table-head, .catalog-table-head { display: none; }
  .shopping-row, .catalog-row { grid-template-columns: 1fr auto; gap: 8px; }
  .shopping-product-cell { grid-column: 1 / -1; }
  .department-cell { padding-left: 34px; }
  .shopping-row .row-actions, .catalog-row .row-actions { grid-column: 2; grid-row: 1 / span 2; }
  .quick-inline { width: 100%; }
  .quick-inline input { min-width: 0; }
}


/* Fix 1: native select/dropdown visibility on mobile */
select,
#catalogDepartment,
#shoppingSortSelect {
  color: #243547;
  background-color: #fff;
  -webkit-text-fill-color: #243547;
}
#catalogDepartment option {
  color: #243547;
  background: #fff;
}
#catalogDialog .dialog-form {
  max-height: 88vh;
  overflow: auto;
}
