:root {
  --pico-form-element-spacing-vertical: 0.25rem;
  --pico-form-element-spacing-horizontal: 1rem;
  --sidebar-width: 240px;
  --sidebar-background-color: rgba(20, 68, 51, 0.05);
  --topbar-height: 3rem;
}

[data-theme="light"],
:root:not([data-theme="dark"]) {
  --pico-background-color: rgb(250, 249, 245);
  --pico-primary: #144433;
  --pico-primary-background: #0d5b64;
  --pico-primary-hover: #0c606b;
  --pico-primary-hover-background: #09464e;
  --pico-primary-border: teal;
  --pico-muted-border-color: #80978f;
  --secondary: #3A7F62;
  --secondary-hover: #2d614c;
}

html,
body {
  min-height: 100%;
  padding: 0;
  margin: 0;
}

body {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr auto;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main"
    "sidebar footer";
  background: linear-gradient(90deg, var(--sidebar-background-color) var(--sidebar-width), transparent var(--sidebar-width));
}

body.env-dev {
  background-color: #d2d8d2;
}

/* Logged-out pages: no sidebar and no topbar — collapse their column/row + drop the strip. */
body.no-sidebar {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "topbar"
    "main"
    "footer";
  background: none;
  min-height: 100vh;
}

body.no-sidebar .topbar {
  display: none;
}

/* Center the logged-out content (e.g. the login form) over the whole viewport:
   main spans full width and (with topbar/footer hidden) fills the full height. */
body.no-sidebar .footer {
  display: none;
}

body.no-sidebar .main-content {
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body.no-sidebar .popup-form {
  width: 100%;
  max-width: 400px;
}

/* ============================== SIDEBAR ============================== */

.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--pico-muted-border-color);
  border-radius: 2;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  /* background: var(--pico-background-color); */
  background: var(--sidebar-background-color);
}

.sidebar.env-dev {
  /* background-color: #e2f5e6; */
}

.sidebar-logo {
  padding-bottom: 0.25rem;
  /* border-bottom: 1px solid var(--pico-muted-border-color); */
}

.sidebar-logo h1 {
  --pico-font-family: Chango, cursive;
  --pico-font-size: 1.875rem;
  --pico-font-weight: 400;
  --pico-typography-spacing-vertical: 0.25rem;
  margin: 0;
}

.sidebar-logo a {
  text-decoration: none;
  color: inherit;
}

.sidebar-project form {
  margin: 0;
}

.sidebar-project select {
  margin: 0;
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
  font-size: 0.75rem;
  height: auto;
  width: 100%;
}

/* ============================== SIDEBAR NAV ============================== */

.sidebar-nav {
  display: block;
  flex: 1;
}

.sidebar-nav > ul {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.1rem;
}

.nav-item {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item > a,
.nav-item-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  font-size: 0.9rem;
  width: 100%;
  margin: 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  justify-content: space-between;
  box-sizing: border-box;
}

.nav-item > a:hover,
.nav-item-toggle:hover {
  background: rgba(20, 68, 51, 0.1);
  color: inherit;
}

.nav-item > a.active,
.nav-item-toggle.active {
  color: var(--pico-primary);
  font-weight: bold;
  /* border-left: 3px solid var(--pico-primary); */
  /* padding-left: calc(0.75rem - 3px); */
  /* background: rgba(120, 168, 151 ); */
  background: rgba(20, 68, 51, 0.2);
  /* background: rgba(20, 68, 51, 0.185); */
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.1rem 0 0 1rem;
  list-style: none;
  margin: 0;
  gap: 0;
}

.nav-submenu li:first-child {
  margin-top: 0.35rem;
}

.nav-submenu[hidden] {
  display: none;
}

.nav-submenu li a {
  display: block;
  padding: 0.35rem 0.75rem;
  margin-right: 0.5rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--pico-color);
  font-size: 0.85rem;
}

.nav-submenu li a:hover {
  background: rgba(20, 68, 51, 0.1);
  color: inherit;
}

.nav-submenu li a.active {
  color: var(--pico-primary);
  font-weight: bold;
  background: rgba(20, 68, 51, 0.2);
}

.nav-chevron {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-item-toggle[aria-expanded="true"] .nav-chevron {
  transform: rotate(180deg);
}

/* ============================== TOP BAR ============================== */

.topbar {
  grid-area: topbar;
  border-bottom: 1px solid var(--pico-muted-border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 1rem;
  gap: 0.5rem;
  background: var(--pico-background-color);
}

.topbar-start {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.topbar-logo {
  --pico-font-family: Chango, cursive;
  font-size: 1.25rem;
  text-decoration: none;
  color: inherit;
  font-family: Chango, cursive;
}

.topbar-utility {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.topbar-utility > li {
  display: flex;
  align-items: center;
}

.topbar-utility > li > a {
  padding: 0.25rem 0.5rem;
  text-decoration: none;
  color: var(--pico-color);
  font-size: 0.875rem;
  border-radius: 4px;
}

.topbar-utility > li > a:hover {
  background: rgba(20, 68, 51, 0.08);
  color: var(--pico-color);
}

.topbar-utility > li > a.active {
  color: var(--pico-primary);
  font-weight: bold;
}

.topbar form {
  margin: 0;
}

.topbar .btn {
  margin: 0;
  font-weight: 400;
  padding: 0.25rem 0.5rem;
}

/* Language dropdown in topbar */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-label {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  color: #333;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.875rem;
  border-radius: 4px;
}

.nav-dropdown-label:hover {
  background: rgba(20, 68, 51, 0.08);
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--pico-background-color);
  min-width: 6rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 4px;
  padding: 0.25rem 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  z-index: 200;
  overflow: hidden;
  list-style: none;
  margin: 0;
}

.nav-dropdown-menu[hidden] {
  display: none;
}

.nav-dropdown-menu li {
  padding: 0;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.4rem 1rem;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
  font-size: 0.875rem;
}

.nav-dropdown-menu a:hover {
  background: rgba(67, 100, 13, 0.08);
}

.lang-switcher-current {
  font-size: 0.8rem;
  font-weight: 600;
}

.nav-dropdown-label svg {
  width: 1rem;
  height: 1rem;
  vertical-align: middle;
}

/* ============================== MAIN CONTENT ============================== */

.main-content {
  grid-area: main;
  max-width: 1620px;
  padding: 1rem;
}

/* The schedule page opts out of the global content cap so its calendar can grow
   on wide screens (see .schedule-canvas)... */
.main-content--schedule {
  max-width: none;
}

/* ...but the events-list tab keeps a readable width rather than stretching. */
.main-content--schedule #tapahtumat-tab {
  max-width: 1620px;
}

/* ============================== FOOTER ============================== */

.footer {
  grid-area: footer;
  text-align: center;
  margin: 0;
  /* padding: 0; */
  line-height: 0.1;
  border-top: 1px solid #aaa;
}

/* ============================== ACCESSIBILITY ============================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background: var(--pico-primary);
  color: #fff;
  font-size: 0.875rem;
  text-decoration: none;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  top: 0;
}

/* ============================== BURGER & BACKDROP ============================== */

.burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: #333;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.burger svg {
  width: 1.25rem;
  height: 1.25rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.sidebar-backdrop[data-open="true"] {
  display: block;
}

/* ============================== RESPONSIVE ============================== */

/* Tablet + mobile: burger visible, sidebar off-canvas (< 1024px) */
@media (max-width: 1023px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr auto;
    grid-template-areas:
      "topbar"
      "main"
      "footer";
    padding-left: 0;
    transition: padding-left 0.2s ease;
    background: none;
  }

  body.sidebar-open {
    padding-left: var(--sidebar-width);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 500;
    background: var(--sidebar-background-color);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .burger {
    display: flex;
  }

  .topbar-start {
    display: flex;
  }

  .topbar {
    justify-content: space-between;
    padding: 0 0.75rem;
  }

  /* No backdrop needed for tablet — sidebar pushes content */
  .sidebar-backdrop {
    display: none !important;
  }
}

/* Mobile only: sidebar takes full width as overlay (< 576px) */
/*
@media (max-width: 575px) {
  body.sidebar-open {
    padding-left: 0;
  }

  .sidebar {
    width: 100%;
    box-shadow: none;
  }
*/
/* Backdrop re-enabled for mobile overlay */
/*
  .sidebar-backdrop {
    display: none !important;
  }

  .sidebar-backdrop[data-open="true"] {
    display: block !important;
  }
}
*/

/* ============================== TAGS ============================== */

.tag-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background-color: rgba(20, 68, 51, 0.12);
  color: var(--pico-primary);
  margin-right: 0.25rem;
  white-space: nowrap;
}

.tag-filter-select {
  margin-bottom: 0.75rem;
  width: auto;
}


/* ============================== COMMON STYLES ============================== */

/*---------- Tabs ----------*/

.tabs-container {
  margin-top: 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  /* border-bottom: 2px solid #e0e0e0; */
  margin-bottom: 1.5em;
}

.tab-button {
  padding: 0.25rem 1.5rem 0.75rem 1.5rem;
  background: none;
  border: none;
  position: relative;
  border-bottom: 2px solid transparent;
  /* margin-bottom: -2px; */
  cursor: pointer;
  font-size: 1rem;
  color: #666;
  transition: all 0.3s ease;
}

.tab-button:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

.tab-button:hover {
  color: #0d5b64;
  background: rgba(13, 91, 100, 0.05);
}

.tab-button.active {
  color: var(--pico-primary);
  font-weight: bold;
}

.tab-button.active::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0px;
  width: 100%;
  height: 2px;
  background-color: var(--pico-primary);
  border-radius: 2px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/*---------- Tables ----------*/

table {
  border-collapse: separate;
}

th,
td {
  font-size: 0.75rem;
  /* padding: calc(var(--pico-spacing) / 4) calc(var(--pico-spacing) / 8); */
  padding: 0.3rem 0.1rem;
  vertical-align: middle;
}

th {
  border-bottom: 2px solid green;
  font-weight: bold;
}

td {
  border-bottom: 1px solid green;
  /* border-left: 1px solid green; */
  /* border-right: 1px solid green; */
  /* height: 4rem; */
}

td.nowrap {
  white-space: nowrap;
}

th.amount {
  text-align: right;
  padding-right: 0.5rem;
}

td.amount {
  text-align: right;
  padding-right: 0.5rem;
}

td.account {
  padding-right: 0.5rem;
}

td.status-cell {
  padding-left: 0.2rem;
  width: 5rem;
}

/* td.actions-cell {
  display: flex;
  flex-wrap: wrap;
  padding-left: 0.5rem;
  gap: 0.3rem;
  justify-content: flex-start;
  align-items: center;
} */

.actions-cell {
  white-space: nowrap;
}

.actions-cell form {
  display: inline-block;
  margin: 0;
}

.actions-cell .btn {
  margin: 0 0.2rem 0 0;
}

.action-row {
  margin-bottom: 1rem;
}

/*---------- Buttons ----------*/

.btn {
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  width: auto;
}

.btn-danger {
  background-color: #c62828;
  border-color: #c62828;
  color: #fff;
}

.btn-danger:hover {
  background-color: #b71c1c;
  border-color: #b71c1c;
}

/*---------- Pagination ----------*/

.pagination {
  max-width: 250px;
  margin: 0 auto;
}

/* .pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
}

.pagination a {
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 4px;
  text-decoration: none;
}

.pagination .disabled,
.pagination .current {
  padding: 0.15rem 0.4rem;
  opacity: 0.6;
} */

/*---------- Messages ----------*/

.message-container {
  padding: 0 var(--pico-spacing);
}

.message {
  background-color: #def5ec;
  color: #084c4d;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  border-top: 1px solid var(--pico-primary-border);
  border-bottom: 1px solid var(--pico-primary-border);
  border-right: 1px solid var(--pico-primary-border);
  border-left: 6px solid var(--pico-primary-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: opacity 0.5s ease;
  position: relative;
  padding-right: 2rem;
}

.message-close {
  position: absolute;
  top: 50%;
  right: 0.6rem;
  transform: translateY(-50%);
  background: none;
  border: none;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  display: flex;
  align-items: center;
}

.message-close svg {
  width: 1rem;
  height: 1rem;
}

.message-close:hover {
  opacity: 1;
}

/*---------- Alerts ----------*/

.alert-icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-left: 4px;
}

.alert-overdue {
  color: #e23d3d;
}

.alert-soon {
  color: #f9a825;
}

/*---------- Highlights ----------*/

.highlight {
  max-width: 30rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.highlight.red {
  background-color: #eca1a1;
  border-top: 1px solid #e23d3d;
  border-bottom: 1px solid #e23d3d;
  border-right: 1px solid #e23d3d;
  border-left: 6px solid #e23d3d;
}

.highlight.blue {
  background-color: #80afc9;
  border-top: 1px solid #00507a;
  border-bottom: 1px solid #00507a;
  border-right: 1px solid #00507a;
  border-left: 6px solid #00507a;
}

.highlight.green {
  background-color: #89b390;
  border-top: 1px solid #2d6b47;
  border-bottom: 1px solid #2d6b47;
  border-right: 1px solid #2d6b47;
  border-left: 6px solid #2d6b47;
}

/*---------- Stat cards ----------*/

.stat-card {
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: 6px;
  background: rgba(20, 68, 51, 0.185);
  border: 1px solid rgba(20, 68, 51, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
  min-width: 10rem;
}

.stat-card__label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--pico-muted-color, #666);
}

.stat-card__value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--pico-color);
}

.stat-card__count {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--pico-muted-color, #666);
}

.stat-card--green {
  background: rgba(20, 68, 51, 0.1);
  border-color: rgba(20, 68, 51, 0.5);
}

.stat-card--red {
  background: rgba(226, 61, 61, 0.2);
  border-color: rgba(226, 61, 61, 0.5);
}

.stat-cards-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-cards-row .stat-card {
  margin-bottom: 0;
}

/*---------- Sorting and filtering ----------*/

.sortable-header {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sort-icon {
  width: 14px;
  height: 14px;
}

.filter-row {
  display: none;
}

.filter-row .filter-input {
  width: 100%;
  border: 1px solid #2d6b47;
  padding: 0rem 0rem 0rem 0.2rem;
  height: 1.5rem;
  font-size: 0.75rem;
  margin-bottom: 0;
  color: var(--pico-muted-color);
}

/*---------- Charts ----------*/

.chart-section {
  margin-bottom: 3rem;
}

.chart-section h4 {
  margin-bottom: 1rem;
  color: #333;
}

.chart-wrapper {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chart-wrapper-large {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Make SVG charts responsive */
.chart-wrapper svg,
.chart-wrapper-large svg {
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
}

/*---------- Expandable elements for tables ----------*/

/* Expandable detail card shown under a loan/supplier row (toggled via data-row-toggle). */
.detail-row {
  display: none;
}

.detail-element {
  background-color: #eceeea;
  /* background-color: #e4efed; */
  color: #0d5b64;
  padding: 0.75rem 1.25rem;
  margin: 0.5rem 0;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.detail-element::before {
  /* Primary color stripe */
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background-color: #0d5b64;
}

.detail-element-table th,
.detail-element-table td {
  background-color: #eceeea;
  /* background-color: #e4efed; */
}

/* ============================== LOGIN PAGE ============================== */

.popup-form {
  max-width: 500px;
  margin: 0 auto;
}

/* ============================== UI002 INVOICES PAGE ============================== */

.file-link {
  text-decoration: none;
}

.file-link i {
  width: 1rem;
  height: 1rem;
  color: var(--pico-primary);
  vertical-align: middle;
}

.file-link:hover i {
  color: var(--secondary-hover);
}

.status-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: smaller;
  font-weight: 600;
  /* color: #fff; */
}

.status-1 {
  background-color: #e3f2fd;
  color: #1565c0;
}

.status-2 {
  background-color: #fff8e1;
  color: #ef6c00;
}

.status-3 {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.status-4 {
  background-color: #ffebee;
  color: #c62828;
}

.status-5 {
  background-color: #bfede9;
  color: #4b7975;
}

.invoice-btn {
  padding: 0.1rem;
  border-radius: 5px;
  /* border: 0px; */
  font-size: smaller;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  width: auto;
  min-width: 4rem;
  box-sizing: border-box;
  /* line-height: 1.2; */
}

.btn-pay {
  background-color: #4caf50;
  border-color: #357a37;
}

.btn-reject {
  background-color: #e53935;
  border-color: #8f2321;
}

.btn-check {
  background-color: #f9a825;
  border-color: #9c6918;
}

.btn-reset {
  background-color: #1565c0;
  border-color: #0d3e77
}

.btn-accept {
  background-color: #4caf50;
  border-color: #357a37;
}

/* ============================== EVENTS PAGE ============================== */

.past-event {
  font-style: italic;
  opacity: 0.7;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: 500px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-height: 90vh;
  overflow-y: auto;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 20px;
}

.close:hover,
.close:focus {
  color: #000;
}

/* Event form styling (add modal + edit modal) */
.event-form-field {
  margin-bottom: 10px;
}

#eventForm label,
#editEventModalBody label {
  display: block;
  margin-bottom: 5px;
  /* font-size: smaller; */
  /* font-weight: bold; */
}

#eventForm .checkbox-field,
#editEventModalBody .checkbox-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

#eventForm .checkbox-field label,
#editEventModalBody .checkbox-field label {
  order: 2;
  margin-bottom: 0;
  cursor: pointer;
}

#eventForm .checkbox-field input[type="checkbox"],
#editEventModalBody .checkbox-field input[type="checkbox"] {
  order: 1;
  flex-shrink: 0;
  margin: 0;
}

#eventForm input[type="text"],
#eventForm input[type="date"],
#eventForm input[type="time"],
#eventForm input[type="datetime-local"],
#eventForm textarea,
#eventForm select,
#editEventModalBody input[type="text"],
#editEventModalBody input[type="date"],
#editEventModalBody input[type="time"],
#editEventModalBody input[type="datetime-local"],
#editEventModalBody textarea,
#editEventModalBody select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

#eventForm input:disabled,
#eventForm textarea:disabled,
#editEventModalBody input:disabled,
#editEventModalBody textarea:disabled {
  background-color: #e9ecef;
  cursor: not-allowed;
}

#eventForm .errorlist,
#editEventModalBody .errorlist {
  color: #dc3545;
  font-size: 12px;
  list-style: none;
  padding: 0;
  margin: 5px 0 0 0;
}

.alert-error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 15px;
}

.alert-error ul {
  margin: 0;
  padding-left: 20px;
}

.form-row {
  display: flex;
  gap: 8px;
}

.form-row > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.form-row input {
  width: 100%;
  box-sizing: border-box;
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.split-link {
  font-size: 0.875rem;
  margin-top: 4px;
  text-decoration: none;
}

.split-row {
  align-items: center;
  margin-bottom: 4px;
}

.split-row select,
.split-row input,
.split-row button {
  margin-bottom: 5px;
}

.split-row > div:first-child {
  flex: 2;
}

.split-row > div:nth-child(2) {
  flex: 1;
  min-width: 80px;
}

.split-row > .split-row__remove {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
}

.split-remove-btn {
  padding: 2px 4px;
  line-height: 1;
  width: fit-content;
  min-width: 0 !important;
}

.split-add-btn {
  padding: 4px 8px;
  line-height: 1;
}

.split-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.split-total {
  font-size: 0.9rem;
  margin-left: auto;
}

#account-section {
  margin-bottom: 1.5rem;
}

.split-total--error {
  color: #c62828;
}

.wall-svg-card {
  margin-bottom: 2rem;
}

.wall-svg {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
}

.wall-svg-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.wall-svg-dims {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 6px;
}

.ebtn-primary {
  background-color: #007bff;
  color: white;
}

.ebtn-primary:hover {
  background-color: #0056b3;
}

.ebtn-secondary {
  background-color: #6c757d;
  color: white;
}

.ebtn-secondary:hover {
  background-color: #545b62;
}

/* ============================== UI004 SCHEDULE PAGE ============================== */

/* .schedule-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
} */

.schedule-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.weeks-select-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
  font-size: 0.8rem;
}

.weeks-select-label select {
  width: auto;
  margin: 0;
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
  font-size: 0.8rem;
  height: auto;
}

.btn-schedule-active {
  background-color: var(--pico-primary-background);
  /* color: var(--pico-color); */
  font-weight: bold;
}

.schedule-nav {
  display: flex;
  gap: 0.25rem;
}

/* Calendar width scales with the column count. ~20rem/column preserves the current
   5-week width (1620/5 ≈ 20.25rem) and grows wider as weeks are added; it's a max,
   so on narrower screens the columns still shrink to fit. --n-cols is set inline. */
.schedule-canvas {
  max-width: calc(var(--n-cols, 5) * var(--col-w, 20rem));
}

/* Day columns are narrower than week columns; ~14rem/day keeps 7 days at roughly
   the prior width and lets 14/21 days grow toward the full screen. */
.schedule-canvas--day {
  --col-w: 14rem;
}

.schedule-headers {
  display: grid;
  gap: 0.25rem;
}

.schedule-col-header {
  background-color: var(--pico-primary);
  color: #fff;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
}

.schedule-col-header.current-col {
  box-shadow: inset 0 0 0 5px #5ecfb1;
}

/* Weekend day-column headers get a distinct (muted) background. Tunable. */
.schedule-col-header.weekend-col {
  background-color: #5a6b78;
  /* slate — clearly different from the primary green */
}

.col-label {
  font-weight: 600;
}

.col-sublabel {
  font-size: 0.7rem;
  opacity: 0.85;
}

.swimlane-label {
  padding: 0.25rem 0.5rem;
  margin-top: 0.5rem;
  background: var(--pico-primary-background);
  font-size: 0.7rem;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
}

.swimlane-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.today-row {
  margin-bottom: 0.5rem;
}

.btn-today {
  font-size: 0.8rem;
  padding: 0.2rem 0.75rem;
}

.day-nav-arrows {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.swimlane-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.btn-swimlane-toggle {
  font-size: 0.75rem;
}

.swimlane-toggle-row label {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  font-size: 0.875rem;
  cursor: pointer;
  margin-bottom: 0;
}

.swimlane-toggle-row label input {
  margin-bottom: 0;
}

.schedule-grid {
  display: grid;
  gap: 0.25rem;
  grid-auto-rows: auto;
  grid-auto-flow: row dense;
  min-height: 6rem;
}

.schedule-grid--swimlane {
  min-height: 0;
}

.schedule-grid--swimlane .drop-zone {
  min-height: 0.5rem;
}

.drop-zone {
  min-height: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.15s;
}

.drop-zone.drop-highlight {
  background-color: rgba(20, 68, 51, 0.12);
  outline: 2px dashed var(--pico-primary);
}

.event-card {
  position: relative;
  padding: 0.15rem 0.2rem;
  border-radius: 4px;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  /* gap: 0.1rem; */
  cursor: grab;
  border-left: 3px solid transparent;
  overflow: hidden;
}

.event-card:active {
  cursor: grabbing;
}

/* Event (Event.Type.EVENT = 1) are shown in light green */
.event-card.event-type-1 {
  /* background-color: #fff8e1;
  border-left-color: #ef6c00;
  color: #5c3a00; */
  background-color: #c9decb;
  border-left-color: #2e7d32;
  color: #1a3d1c;
}

/* Reviews (Event.Type.REVIEW = 2) are shown in golden yellow */
.event-card.event-type-2 {
  background-color: #ffce7f;
  border-left-color: #bf821f;
  color: #4e3a00;
  /* background-color: #e3f2fd;
  border-left-color: #1565c0;
  color: #0d2f6e; */
}

/* Absences (Event.Type.ABSENCE = 3) are shown in light violet */
.event-card.event-type-3 {
  background-color: #f3e5f5;
  border-left-color: #8e24aa;
  color: #4a148c;
}

/* Deliveries (Event.Type.DELIVERY = 4) are shown in light teal */
.event-card.event-type-4 {
  background-color: #b8e65c;
  border-left-color: #8f9485;
  color: #363931;
}

/* Holidays (Event.Type.HOLIDAY = 5) are shown in light red */
.event-card.event-type-5 {
  background-color: #ffebee;
  border-left-color: #c62828;
  color: #5f1414;
  /* background-color: #f5ecd7;
  border-left-color: #b08900;
  color: #5c4600; */
}

/* .event-card.event-status-fixed {
  background-color: #e3f2fd;
  border-left-color: #1565c0;
  color: #0d2f6e;
} */

.event-card.event-status-planned {
  background-color: #e3f2fd;
  border-left-color: #1565c0;
  color: #0d2f6e;
}


/* Status icons live bottom-right (the worker-avatar cluster owns the top-right corner). The
   container hugs the right edge and shrinks to its content, so icons pack from the right —
   a single icon sits in the corner, a second lands to its left. */
.event-status-icons {
  position: absolute;
  bottom: 0.2rem;
  right: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.event-done-icon {
  width: 0.8rem;
  height: 0.8rem;
  color: #2e7d32;
  stroke: #2e7d32;
}

.event-importance-icon {
  width: 0.8rem;
  height: 0.8rem;
  color: #c62828;
  stroke: #c62828;
}

/* Overlapping worker avatars in the card's top-right corner. */
.event-workers {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  z-index: 1;
  pointer-events: none;
}

.event-workers > .avatar {
  box-shadow: 0 0 0 0.5px #fff;
}

.event-workers > .avatar + .avatar {
  margin-left: -6px;
}

.event-workers-more {
  margin-left: 2px;
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--pico-color);
}

.event-context-menu {
  position: absolute;
  z-index: 200;
  background: var(--pico-background-color);
  border: 1px solid #aaa;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  padding: 0.25rem 0;
  min-width: 10rem;
}

.event-context-menu a {
  display: block;
  padding: 0.2rem 0.5rem;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
  font-size: 0.75rem;
}

.event-context-menu a:hover {
  background: rgba(13, 91, 100, 0.08);
}

.touch-drag-clone {
  position: fixed;
  opacity: 0.8;
  z-index: 1000;
  pointer-events: none;
  transform: translate(-50%, -50%);
  cursor: grabbing;
}

.event-headline {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.event-headline:hover {
  text-decoration: underline;
}

.event-meta {
  opacity: 0.75;
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-events {
  grid-column: 1 / -1;
  font-style: italic;
  opacity: 0.6;
  font-size: 0.85rem;
  padding: 0.5rem;
}

/* ============================== UI003 BOOKKEEPING ACCOUNTS PAGE ============================== */

/* Configurable constants */
:root {
  --toggle-w: 1.25rem;
  /* fixed width for the chevron area */
  --indent-step: 1.25rem;
  /* width added per tree level */
  --firstcol-width: 8rem;
  /* reserve enough width so other cols never shift */
}

.accounts-actions {
  margin-bottom: 1rem;
}

/* Fix the first column width (prevents layout jump on expand/collapse) */
.accounts .col-number,
.accounts td.account-number,
.accounts th:first-child {
  width: var(--firstcol-width);
  /* padding: calc(var(--pico-spacing)/ 8) calc(var(--pico-spacing)/10); */
}

/* First cell layout: [toggle-box][indent][label] — td stays table-cell */
.account-number {
  white-space: nowrap;
  vertical-align: middle;
}

.account-number > * {
  vertical-align: middle;
}

/* 1) Toggle area: fixed width always present */
.toggle-box {
  width: var(--toggle-w);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex: 0 0 var(--toggle-w);
}

.toggle {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  color: green;
}

.toggle.placeholder {
  width: 1em;
  height: 1em;
  visibility: hidden;
}

/* Feather icon sizing + smooth rotation */
.toggle svg {
  width: 1em;
  height: 1em;
  transition: transform 0.2s ease-in-out;
  display: block;
  transform-origin: 50% 50%;
}

.toggle[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

/* 2) Indent spacer: exact, predictable width = level × step */
.indent {
  display: inline-block;
  width: calc(var(--level, 0) * var(--indent-step));
  vertical-align: middle;
}

/* Label (the number) */
.account-number .label {
  margin-left: 0.25rem;
}

/* Optional: visual hint for roots */
.account-row.is-root td {
  font-weight: 600;
}

/* An account's expenses are shown as one sub-table inset under the account row. */
.account-expenses-row > td {
  /* padding: 0.4rem 4rem 0.6rem calc(var(--toggle-w) + var(--level, 1) * var(--indent-step)); */
  padding: 0.4rem 4rem 0.6rem 4rem;
}

.expense-subtable {
  width: 100%;
  /* consistent width, independent of content */
  margin: 0;
  font-size: 0.85rem;
  background-color: #eceeea;
  /* subtle theme-green tint — tunable */
  /* Separate model so the table's side padding insets the cells (and the header
     divider) from the tinted block's edges. */
  border-collapse: separate;
  border-spacing: 0;
  padding: 0 0.75rem;
}

/* Cancel the inherited .accounts first-column width / borders for the sub-table,
   and let the table's tint show through the cells. Qualified with .accounts so
   these beat `.accounts th:first-child` etc. */
.accounts .expense-subtable th,
.accounts .expense-subtable td {
  width: auto;
  padding: 0.15rem 0.75rem;
  border: none;
  background: transparent;
}

/* Divider under the sub-table header — a lighter tone than the main table's. */
.accounts .expense-subtable thead th {
  border-bottom: 1px solid rgba(128, 151, 143, 0.45);
}

.expense-subtable .amount {
  text-align: right;
  white-space: nowrap;
}

/* Keep the date column to its content width so it doesn't hog horizontal space.
   width:1% + nowrap shrinks the column to fit its contents. Qualified with
   .accounts so it beats the `width:auto` cell rule above. */
.accounts .expense-subtable th:first-child,
.accounts .expense-subtable td.date {
  width: 1%;
  /* max-width: 6rem; */
  white-space: nowrap;
}

.expense-subtable td.nowrap {
  white-space: nowrap;
}

.accounts tr.grand-total-row {
  border-bottom: none;
}

.accounts td.grand-total-label {
  font-weight: bold;
  font-size: large;
  text-align: right;
  padding-right: calc(var(--pico-spacing) * 2);
}

.accounts td.grand-total-value {
  font-weight: bold;
  font-size: large;
}

/* ============================== UI006 HOURS PAGE ============================== */

.btn-engine-start {
  width: 5rem;
  height: 5rem;
  min-width: 5rem;
  min-height: 5rem;
  border-radius: 50%;
  border: 6px solid #3a9e6e;
  background: radial-gradient(circle at 35% 35%, #888888, #383838);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 2px rgba(255, 255, 255, 0.2);
  transition: box-shadow 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
  line-height: 1.4;
  overflow: hidden;
}

.btn-engine-start:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-engine-start:active {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: translateY(1px);
}

.btn-engine-stop {
  border-color: #c62828;
  background: radial-gradient(circle at 35% 35%, #888888, #383838);
}

.work-timer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.work-timer-counter {
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.work-timer-gps-status {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
}

.hours-grid {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.hours-cell {
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: 4px;
  padding: 0.5rem;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hours-cell.current-col {
  border-color: var(--pico-primary);
}

.hours-cell--clickable {
  cursor: pointer;
}

.hours-cell--clickable:hover {
  border-color: var(--pico-primary);
  background: var(--pico-card-sectioning-background-color, #f5f5f5);
}

.hours-total {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.work-session {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  margin-bottom: 0.15rem;
}

.session-active {
  color: var(--pico-primary);
  font-weight: 600;
}

.geofence-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

.geofence-icon--ok {
  color: var(--pico-color-green-500, #22c55e);
}

.geofence-icon--warn {
  color: var(--pico-color-orange-500, #f97316);
}

.geofence-icon--none {
  color: var(--pico-muted-color);
}

.geofence-site-name {
  margin-left: 0.25rem;
  color: var(--pico-muted-color);
}


/* ============================== UI007 SUPPLIERS PAGE ============================== */

.supplier-row {
  cursor: pointer;
}

/* ============================== UI008 REPORTS PAGE ============================== */

.report-form-wrapper {
  max-width: 500px;
  margin: 0 auto;
  padding: 1rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}


/* ============================== UI009 PROFILE PAGE ============================== */

.notificationform {
  max-width: 500px;
  margin: 0 0;
}

/* ============================== UI011 FINANCE PAGE ============================== */

.loan-row {
  cursor: pointer;
}

.euribor-actions {
  display: flex;
  /* justify-content: flex-end; */
  margin-bottom: var(--pico-spacing);
}

.euribor-actions button {
  margin: 0;
  padding: 0.4rem 0.8rem;
  font-weight: 400;
}

/* ============================== UI012 SITE DIARY PAGE ============================== */

/* "Ota kuva" only makes sense on touch devices (it opens the camera). On a desktop with a
   mouse it just opens the same file dialog as "Valitse kuvia", so hide it there. */
/* The camera trigger is a <label> (Pico renders labels as full-width blocks), so force it to size
   to its text like the sibling buttons. */
.diary-camera-btn {
  display: inline-block;
  width: auto;
}

@media (hover: hover) and (pointer: fine) {
  .diary-camera-btn {
    display: none;
  }
}

/* Hide an element visually while keeping it in the render tree. Used for the camera file input:
   a display:none/hidden file input makes some Android browsers drop the capture="environment"
   hint, so it must remain rendered even though it isn't shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.diary-previews,
.diary-photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.diary-preview {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 12rem;
}

.diary-preview img {
  width: 12rem;
  height: 9rem;
  object-fit: cover;
  border-radius: 4px;
}

.diary-preview input {
  margin: 0;
  font-size: 0.8rem;
}

.diary-remove {
  align-self: flex-end;
  padding: 0.2rem 0.5rem;
  line-height: 0;
}

.diary-remove svg {
  width: 1rem;
  height: 1rem;
  vertical-align: middle;
}

/* An existing photo marked for deletion on save. */
.diary-preview--deleting {
  opacity: 0.45;
}

.diary-entry {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.diary-entry__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  /* Override Pico's `article > header` negative margins/background so the entry's
     top border stays visible and the header doesn't render as a full-width bar. */
  margin: 0;
  padding: 0.5rem 0rem;
  background: none;
}

.diary-entry__author {
  color: var(--pico-muted-color);
  font-size: 0.85rem;
}

/* The diary edit form reuses .report-form-wrapper but gets more room. */
.diary-edit-wrapper {
  max-width: 900px;
}

.diary-entry__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.diary-entry__actions form {
  margin: 0;
}

.diary-entry__actions .btn {
  margin: 0;
}

.diary-photo {
  margin: 0;
  width: 10rem;
}

.diary-photo img {
  width: 10rem;
  height: 7.5rem;
  object-fit: cover;
  border-radius: 4px;
}

.diary-photo figcaption {
  font-size: 0.8rem;
}

/* ============================== AVATARS ============================== */

/* Round user avatar — either the uploaded photo or an initials circle (see partials/avatar.html). */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  overflow: hidden;
  background-color: var(--secondary);
  color: #fff;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
}

img.avatar {
  /* photos fill the circle; the border is only meaningful for overlapping clusters (see below) */
  border: none;
}

.avatar--sm {
  width: 18px;
  height: 18px;
  font-size: 0.5rem;
}

.avatar--md {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

.avatar--lg {
  width: 96px;
  height: 96px;
  font-size: 2rem;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar-form {
  margin: 0.5rem 0 1rem;
}

/* ============================== ASSIGNEE PICKER (chips + datalist) ============================== */

.assignee-field {
  margin-bottom: var(--pico-spacing);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(20, 68, 51, 0.12);
  font-size: 0.85rem;
}

.chip-remove {
  padding: 0;
  margin: 0;
  width: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}

.assignee-input {
  margin: 0;
}
