@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/resources/fonts/source-sans-3-v19-latin-regular.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/resources/fonts/source-sans-3-v19-latin-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/resources/fonts/source-sans-3-v19-latin-600.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/resources/fonts/source-sans-3-v19-latin-700.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/resources/fonts/source-sans-3-v19-latin-800.woff2") format("woff2");
}

:root {
  color-scheme: dark;

  --bg: #0d100e;
  --surface: #161b18;
  --surface-muted: #1c2220;
  --surface-hover: #232a25;
  --surface-raised: #1f2521;
  --input-bg: #10150f;

  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);

  --text: #e6ede8;
  --muted: #8a958f;

  --accent: #2db886;
  --accent-dark: #3dd099;
  --accent-soft: rgba(45, 184, 134, 0.12);
  --accent-glow: rgba(45, 184, 134, 0.28);

  --danger: #ef6b6b;
  --danger-soft: rgba(239, 107, 107, 0.12);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
  --detail-bg: rgba(45, 184, 134, 0.05);
  --detail-border: rgba(45, 184, 134, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Sans 3", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.45;
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 20px;
  width: min(100%, 400px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-panel > div {
  display: grid;
  gap: 4px;
}

.login-panel h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.login-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.login-panel p.error {
  color: var(--danger);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #0d100e;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  transition: background 150ms ease, box-shadow 150ms ease, transform 80ms ease;
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.button-link {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
  background: var(--accent);
  color: #0d100e;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.secondary-button {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  background: var(--surface-hover);
}

.invoice-start-button {
  background: var(--accent);
  box-shadow: 0 4px 16px rgba(45, 184, 134, 0.2);
  color: #0d100e;
  white-space: nowrap;
}

.invoice-start-button:hover,
.invoice-start-button:focus-visible {
  background: var(--accent-dark);
}

.back-link {
  background: transparent;
  color: var(--muted);
  padding-inline: 6px;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 4px;
}

input {
  width: 100%;
  min-height: 51px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 12px;
  border-color: var(--line-strong);
}

textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
}

textarea:focus {
  outline: 3px solid var(--accent-glow);
  outline-offset: 2px;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0 12px;
  border-color: var(--line-strong);
  font: inherit;
}

.ts-wrapper {
  font: inherit;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
  min-height: 51px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  box-shadow: none;
  border-color: var(--line-strong);
  font: inherit;
  padding: 4px 36px 4px 12px;
}

.ts-wrapper.single .ts-control {
  display: flex;
  align-items: center;
}

.ts-wrapper.focus .ts-control {
  border-color: var(--line);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ts-wrapper .ts-control > input {
  min-height: 0;
}

.ts-wrapper.single .ts-control .item {
  max-width: 100%;
  min-width: 0;
}

.ts-wrapper .ts-dropdown {
  border-color: var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  font: inherit;
}

.ts-wrapper .option {
  padding: 9px 12px;
}

.ts-wrapper .active {
  background: var(--surface-muted);
  color: var(--text);
}

.ts-project-option {
  display: grid;
  gap: 2px;
  min-width: 0;
  line-height: 1.15;
}

.ts-project-option > span,
.ts-project-option > small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ts-project-option > small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid var(--accent-glow);
  outline-offset: 2px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* Custom scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Topbar + panel transitions */
.topbar,
.quick-entry,
.panel,
.metric {
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 4vw, 48px);
  background: rgba(22, 27, 24, 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.section-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

#system-status {
  display: none;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.menu-shell {
  position: relative;
}

.icon-menu-button {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
}

.hamburger-lines {
  display: grid;
  gap: 4px;
  width: 18px;
}

.hamburger-lines span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.app-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 110;
  display: grid;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: modal-in 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 700;
  padding: 10px 12px;
  text-decoration: none;
  transition: background 120ms ease;
}

.app-menu a .menu-icon {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 120ms ease;
}

.app-menu a:hover .menu-icon,
.app-menu a[aria-current="page"] .menu-icon {
  opacity: 1;
}

.app-menu a:hover,
.app-menu a[aria-current="page"] {
  background: var(--surface-muted);
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.icon-text-button svg {
  flex-shrink: 0;
}

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

.hidden {
  display: none !important;
}

.layout {
  display: grid;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 56px;
}

.quick-entry,
.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.quick-entry,
.panel {
  padding: 22px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.inline-filter {
  display: grid;
  gap: 4px;
  min-width: 240px;
}

.inline-filter input,
.inline-filter select,
.inline-filter .ts-control {
  min-height: 51px;
}

#entry-result {
  color: var(--muted);
  min-height: 22px;
  text-align: right;
}

#entry-result.error {
  color: var(--danger);
}

label:not(.checkbox-field) {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.entry-row {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1.2fr) minmax(260px, 1.4fr) 170px 132px auto;
  gap: 14px;
  align-items: end;
}

.entry-row > div,
.date-filter > div:not(.preset-buttons):not(.date-filter-actions),
.review-filters > div,
.user-form > div {
  display: grid;
  gap: 4px;
}

.settings-form {
  display: grid;
  gap: 16px;
}

.settings-page-form {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.settings-grid > div {
  display: grid;
  gap: 6px;
}

.settings-form > div {
  display: grid;
  gap: 6px;
}

.settings-prompt-field textarea,
.service-summary-field textarea {
  min-height: 150px;
  resize: vertical;
}

.service-summary-field {
  max-width: 680px;
}

.service-summary-input {
  position: relative;
}

.service-summary-input textarea {
  padding-bottom: 54px;
  width: 100%;
}

.service-summary-input button {
  bottom: 10px;
  min-height: 34px;
  padding: 0 12px;
  position: absolute;
  right: 10px;
}

.settings-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
}

.settings-field-actions {
  display: flex;
  margin-top: 4px;
}

.settings-subsection {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding-top: 18px;
}

.settings-subsection h3,
.settings-subsection p {
  margin: 0;
}

label.switch-field {
  align-items: center;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  gap: 12px;
  position: relative;
  user-select: none;
  width: fit-content;
}

.switch-field input {
  cursor: pointer;
  height: 100%;
  inset: 0;
  margin: 0;
  min-height: 0;
  opacity: 0;
  position: absolute;
  width: 100%;
  z-index: 1;
}

.switch-control {
  background: #3a423d;
  border-radius: 18px;
  flex: 0 0 auto;
  height: 26px;
  position: relative;
  transition: background 160ms ease;
  width: 46px;
}

.switch-control::after {
  background: #f0f5f1;
  border-radius: 50%;
  content: "";
  height: 20px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 160ms ease;
  width: 20px;
}

.switch-field input:checked + .switch-control {
  background: var(--accent);
}

.switch-field input:checked + .switch-control::after {
  transform: translateX(20px);
}

.switch-field input:focus-visible + .switch-control {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.invoice-number-settings {
  margin-top: 18px;
  max-width: 760px;
}

.invoice-number-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(240px, 1fr) auto;
}

.invoice-number-form > div {
  display: grid;
  gap: 6px;
}

.invoice-number-form [role="status"] {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
}

.compact-checkbox {
  height: 16px;
  margin: 0;
  min-height: 0;
  width: 16px;
}

label.compact-checkbox {
  font-size: 14px;
  width: auto;
}

.date-filter {
  display: grid;
  grid-template-columns: 170px 170px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.date-filter-actions {
  display: flex;
  justify-content: flex-end;
  align-items: end;
}

.date-filter-actions .icon-text-button {
  min-height: 42px;
  white-space: nowrap;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.review-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  gap: 10px;
  margin-bottom: 14px;
}

.preset-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.preset-buttons button {
  min-height: 42px;
  border-radius: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 0 14px;
  font-size: 13px;
}

.preset-buttons button:last-child {
  border-right: 0;
}

.preset-buttons button:hover {
  background: var(--surface-hover);
}

.preset-buttons .active-filter {
  background: var(--accent) !important;
  color: #0d100e !important;
  font-weight: 700;
  box-shadow: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.metric {
  min-height: 104px;
  padding: 20px;
  border-top: 3px solid var(--accent);
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--accent-soft), transparent 60%);
  pointer-events: none;
  opacity: 0.6;
}

.metric-link {
  color: inherit;
  text-decoration: none;
}

.metric-link:hover,
.metric-link:focus-visible {
  border-color: rgba(31, 122, 91, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.compact-summary {
  margin: 18px 0;
}

.notice {
  border-radius: 8px;
  margin-top: 14px;
  padding: 12px 14px;
}

.notice.warning {
  background: rgba(255, 196, 64, 0.1);
  border: 1px solid rgba(255, 196, 64, 0.3);
  color: #ffc840;
}

.invoice-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 18px;
}

.invoice-actions label {
  align-self: center;
  margin-right: -4px;
}

.invoice-editor-row {
  align-items: start;
  display: grid;
  grid-template-columns: 170px minmax(320px, 680px);
  gap: 12px;
  margin-top: 18px;
}

.invoice-editor-row > div {
  display: grid;
  gap: 4px;
}

.compact-action {
  min-height: 36px;
  padding-inline: 12px;
}

.invoice-detail-page {
  background: var(--bg);
}

.invoice-detail-layout {
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 24px;
}

.invoice-status-banner {
  width: min(100%, 210mm);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 800;
  padding: 12px 16px;
}

.invoice-status-banner.status-paid {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.invoice-status-banner.status-canceled {
  border-color: var(--danger);
  color: var(--danger);
}

.invoice-document {
  width: min(100%, 210mm);
  min-height: 297mm;
  padding: 25mm 20mm 22mm;
  background: #fff;
  color: #111;
  box-shadow: 0 10px 35px rgba(24, 32, 27, 0.14);
  font-family: "Source Sans 3", sans-serif;
  font-size: 11pt;
  line-height: 1.35;
  position: relative;
}

.invoice-birds {
  height: auto;
  position: absolute;
  right: 27mm;
  top: 19mm;
  width: 50mm;
}

.invoice-letterhead {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(230px, 1fr);
  gap: 20mm;
  min-height: 67mm;
}

.sender-return-address {
  margin: 25mm 0 6mm;
  font-size: 8.5pt;
}

.invoice-recipient address {
  display: grid;
  font-size: 12pt;
  font-style: normal;
}

.invoice-sender {
  padding-top: 32mm;
}

.invoice-sender > strong {
  display: block;
  margin-bottom: 5mm;
  font-size: 12pt;
}

.invoice-sender dl,
.invoice-sender dd {
  margin: 0;
}

.invoice-sender dl {
  display: grid;
  gap: 1.5mm;
}

.invoice-sender dl > div {
  display: grid;
  grid-template-columns: 23mm minmax(0, 1fr);
}

.invoice-sender dt {
  font-weight: 700;
}

.invoice-date-row {
  margin-top: 5mm;
}

.invoice-content h2 {
  margin: 10mm 0 11mm;
  font-size: 13pt;
}

.invoice-content > p {
  margin: 0 0 10mm;
}

.invoice-position-table {
  min-width: 0;
  font-size: 10.5pt;
}

.invoice-position-table th,
.invoice-position-table td {
  border-color: #333;
  padding: 2.5mm 2mm;
  vertical-align: middle;
}

.invoice-position-table th {
  color: #111;
  font-size: 9pt;
  font-style: italic;
  font-weight: 400;
  text-transform: none;
}

.invoice-position-table th:first-child {
  width: 11mm;
}

.invoice-position-table th:nth-child(2) {
  width: 22mm;
}

.invoice-position-table th:nth-child(4),
.invoice-position-table th:nth-child(5) {
  width: 27mm;
}

.invoice-service-summary {
  margin-top: 1.5mm;
  font-style: italic;
  white-space: pre-line;
}

.invoice-position-table small {
  display: block;
  margin-top: 1.5mm;
  font-size: 9pt;
  font-style: italic;
}

.invoice-position-table tfoot th,
.invoice-position-table tfoot td {
  border-bottom: 0;
}

.invoice-position-table tfoot th {
  text-align: right;
}

.invoice-position-table .invoice-grand-total th,
.invoice-position-table .invoice-grand-total td {
  border-top: 1px solid #333;
  font-size: 11pt;
  font-style: normal;
  font-weight: 700;
}

.invoice-footer-copy {
  margin-top: 12mm;
}

.invoice-footer-copy p {
  margin: 0 0 6mm;
  white-space: pre-line;
}

.invoice-signature {
  display: block;
  height: auto;
  margin: 7mm 0 6mm;
  width: 27mm;
}

#invoice-signature-name,
.invoice-signature-name {
  margin-top: 0;
}

.invoice-source-panel {
  width: min(100%, 210mm);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-controls button {
  min-height: 36px;
  padding: 0 10px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.projects-table {
  min-width: 760px;
}

.customers-table {
  min-width: 780px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 10px;
  text-align: left;
  vertical-align: middle;
}

/* Zebra striping for data tables */
tbody tr:nth-child(even):not(.section-row):not(.section-total-row):not(.empty-row):not(.editing-row) td {
  background: rgba(255, 255, 255, 0.018);
}

/* Smooth hover on data rows */
tbody tr:not(.section-row):not(.empty-row) td {
  transition: background 120ms ease;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.number {
  text-align: right;
  white-space: nowrap;
}

.section-row td {
  background: var(--surface-hover);
  border-bottom: 1px solid var(--line);
  border-top: 14px solid transparent;
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.06em;
  padding-top: 16px;
  padding-bottom: 16px;
  text-transform: uppercase;
}

.section-row span {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
}

.section-total-row td {
  background: var(--surface-muted);
  border-bottom: 0;
  color: var(--text);
  font-weight: 800;
}

.project-row {
  cursor: pointer;
  transition: background 120ms ease;
}

.customer-row {
  cursor: pointer;
  transition: background 120ms ease;
}

.project-row:hover td,
.project-row:focus td {
  background: var(--surface-hover) !important;
}

.customer-row:hover td,
.customer-row:focus td {
  background: var(--surface-hover) !important;
}

.project-row[aria-expanded="true"] td,
.project-row[aria-expanded="true"]:hover td,
.project-row[aria-expanded="true"]:focus td {
  background: var(--detail-bg) !important;
  border-top: 3px solid var(--accent);
}

.project-row[aria-expanded="true"] td:first-of-type {
  border-left: 3px solid var(--accent);
}

.project-row[aria-expanded="true"] td:last-of-type {
  border-right: 3px solid var(--accent);
}

.customer-row[aria-expanded="true"] td,
.customer-row[aria-expanded="true"]:hover td,
.customer-row[aria-expanded="true"]:focus td {
  background: var(--detail-bg) !important;
}

.project-row:focus {
  outline: 3px solid var(--accent-glow);
  outline-offset: -3px;
}

.customer-row:focus {
  outline: 3px solid var(--accent-glow);
  outline-offset: -3px;
}

.row-expander {
  color: var(--accent-dark);
  display: inline-block;
  font-size: 13px;
  margin-right: 8px;
  width: 12px;
  transition: transform 200ms ease;
}

.project-row[aria-expanded="true"] .row-expander,
.customer-row[aria-expanded="true"] .row-expander {
  transform: rotate(90deg);
}

.project-details-row td {
  background: var(--detail-bg);
  padding: 24px 10px 24px 34px;
  border-bottom: 2px solid var(--accent);
  border-left: 3px solid var(--accent);
  border-right: 3px solid var(--accent);
}

.customer-details-row td {
  background: var(--detail-bg);
  padding: 24px 10px 24px 34px;
  border-bottom: 2px solid var(--accent);
  border-left: 3px solid var(--accent);
}

.customer-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.customer-details-main {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  width: 100%;
}

.customer-detail {
  min-width: 150px;
  max-width: 360px;
}

.customer-detail-wide {
  flex-basis: 280px;
}

.customer-detail span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.customer-detail strong {
  display: block;
  margin-top: 4px;
  font-weight: 600;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.customer-detail-actions {
  align-self: flex-end;
  margin-left: auto;
}

.customer-detail-information,
.customer-detail-tasks,
.project-detail-information,
.project-detail-tasks {
  display: grid;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--detail-border);
  justify-content: start;
  justify-items: start;
}

.customer-detail-information > span,
.customer-detail-tasks > span,
.project-detail-information > span,
.project-detail-tasks > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.project-details {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  gap: 6px;
  background: transparent;
}

.project-detail-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  margin-left: auto;
}

.project-details span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.project-details strong {
  display: block;
  margin-top: 4px;
}

.empty-row td {
  color: var(--muted);
  padding: 32px 10px;
  text-align: center;
  font-size: 14px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.actions-cell {
  text-align: right;
  white-space: nowrap;
}

.user-edit-name {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.icon-button {
  min-height: 34px;
  padding: 0 10px;
}

.icon-only-button {
  display: inline-grid;
  width: 38px;
  min-height: 38px;
  padding: 0;
  place-items: center;
  border-radius: 8px;
}

.pagination-controls .icon-only-button {
  padding: 0;
}

.button-icon {
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.table-value-icon {
  display: inline-block;
  vertical-align: middle;
}

.edit-icon {
  -webkit-mask-image: url("/resources/edit_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/edit_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.delete-icon {
  -webkit-mask-image: url("/resources/delete_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/delete_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.visibility-icon {
  -webkit-mask-image: url("/resources/visibility_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/visibility_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.euro-symbol-icon {
  -webkit-mask-image: url("/resources/euro_symbol_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/euro_symbol_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.close-icon {
  -webkit-mask-image: url("/resources/close_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/close_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.backward-icon {
  -webkit-mask-image: url("/resources/arrow_back_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/arrow_back_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.forward-icon {
  -webkit-mask-image: url("/resources/arrow_forward_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/arrow_forward_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.add-notes-icon {
  -webkit-mask-image: url("/resources/add_notes_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("/resources/add_notes_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 107, 107, 0.25);
}

.danger-button:hover {
  background: rgba(239, 107, 107, 0.2);
}

.compact-input {
  min-height: 36px;
  padding: 0 8px;
}

.number-input {
  text-align: right;
}

.editing-row td {
  background: var(--surface-hover);
  vertical-align: middle;
}

.badge {
  align-self: start;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  text-transform: uppercase;
}

.modal {
  width: min(92vw, 560px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.invoice-confirm-modal {
  width: min(96vw, 1060px);
  max-width: none;
  height: 94vh;
  max-height: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.invoice-confirm-modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.invoice-confirm-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  background: var(--surface);
}

.invoice-confirm-header,
.invoice-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
}

.invoice-confirm-header {
  border-bottom: 1px solid var(--line);
}

.invoice-confirm-header h2,
.invoice-confirm-header p {
  margin: 0;
}

.invoice-confirm-actions {
  border-top: 1px solid var(--line);
}

.invoice-confirm-scroll {
  overflow: auto;
  padding: 18px;
  background: var(--bg);
}

.invoice-document-preview {
  margin: 0 auto;
}

.customer-modal {
  width: min(94vw, 780px);
}

.customer-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: 65vh;
  overflow-y: auto;
  padding: 2px;
}

.customer-form-grid > div {
  display: grid;
  gap: 4px;
}

.customer-form-wide {
  grid-column: 1 / -1;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.modal-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
  background: var(--surface);
}

.member-list {
  display: grid;
  gap: 8px;
  max-height: 45vh;
  overflow: auto;
}

.member-option {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 120ms ease;
}

.member-option:hover {
  border-color: var(--line-strong);
}

.member-option small {
  display: block;
  color: var(--muted);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.project-details-main {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.information-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.information-chip {
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
  font: inherit;
  text-align: left;
}

.information-chip:hover {
  background: var(--surface-hover);
}

.task-list {
  display: grid;
  gap: 8px;
  width: 100%;
}

.task-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--detail-border);
  border-radius: 10px;
  background: var(--surface-muted);
  transition: border-color 120ms ease, background 120ms ease;
}

.task-row:hover {
  border-color: var(--accent-glow);
}

.task-row.task-done {
  opacity: 0.78;
}

.task-row.task-done .task-title-button {
  text-decoration: line-through;
}

.task-row-main {
  display: grid;
  grid-template-columns: 1fr max-content;
  gap: 6px;
  min-width: 400px;
  align-items: center;
}

.task-title-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.task-title-button:hover {
  color: var(--text);
  background: transparent;
}

.task-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-meta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.task-meta-badge.task-meta-done {
  background: var(--accent-soft);
}

.task-status-toggle {
  margin-top: 2px;
}

.information-view-body {
  display: grid;
  gap: 14px;
}

.information-content {
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.information-attachment,
.information-inline-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
}

.information-attachment a,
.information-inline-attachment a {
  color: var(--accent-dark);
  font-weight: 600;
}

@media (max-width: 860px) {
  .topbar,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions,
  .modal-actions,
  .modal-button-row,
  .invoice-confirm-header,
  .invoice-confirm-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 42px 1fr 1fr;
  }

  .invoice-detail-actions {
    grid-template-columns: 1fr 1fr;
  }

  .entry-row,
  .date-filter,
  .invoice-editor-row,
  .invoice-number-form,
  .project-details,
  .review-filters,
  .settings-page-form,
  .settings-grid,
  .user-form,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .invoice-detail-layout {
    padding: 12px;
  }

  .invoice-document {
    min-height: 0;
    padding: 24px;
  }

  .invoice-letterhead {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .sender-return-address {
    margin-top: 20px;
  }

  .invoice-sender {
    padding-top: 0;
  }

  .invoice-birds {
    display: block;
    margin-left: auto;
    position: static;
    width: 130px;
  }

  .customer-form-grid {
    grid-template-columns: 1fr;
  }

  .customer-form-wide {
    grid-column: auto;
  }

  #entry-result {
    text-align: left;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body.invoice-detail-page {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .invoice-detail-layout {
    display: block;
    padding: 0;
  }

  .invoice-document {
    width: 210mm;
    min-height: 297mm;
    padding: 25mm 20mm 22mm;
    box-shadow: none;
  }
}


@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Dialog backdrop animation */
dialog.modal[open],
dialog.invoice-confirm-modal[open] {
  animation: modal-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
