:root {
  --bg: #f9f9f9;
  --surface: #ffffff;
  --surface-soft: #f3f3f3;
  --text: #202020;
  --muted: #555f58;
  --line: #cccccc;
  --accent: #d60000;
  --accent-strong: #a90000;
  --brand-green: #47ed60;
  --brand-black: #1c1c1c;
  --warn: #d60000;
  --link: #d60000;
  --shadow: 0 12px 28px rgba(28, 35, 41, 0.08);
  --touch-shadow: 0 18px 36px rgba(28, 35, 41, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 8px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 1.2rem;
  white-space: nowrap;
}

.app-header img,
.brand-logo,
img.brand-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 68px;
  object-fit: contain;
  flex: 0 0 auto;
}

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

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  color: #fff;
  background: #f9f9f9;
  border-radius: 8px;
  font-weight: 800;
}

.nav a:hover {
  filter: brightness(0.94);
  text-decoration: none;
}

.nav a.nav-invoice {
  background: var(--accent);
}

.nav a.nav-customers {
  background: var(--brand-black);
}

.nav a.nav-calendar {
  background: #126cbd;
}

.nav a.nav-cash {
  color: #111;
  background: var(--brand-green);
}

.nav a.nav-exports {
  color: #111;
  background: #f2d64b;
}

.nav a.nav-icon {
  justify-content: center;
  width: 46px;
  padding: 8px;
  color: var(--text);
  background: #f9f9f9;
}

.nav a.nav-icon .material-symbols-outlined {
  font-size: 1.7rem;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.page-head,
.section-title,
.actions,
.inline-form,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-head {
  margin-bottom: 24px;
}

.page-head h1,
.content-section h2,
.panel h2,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.muted,
.note {
  color: var(--muted);
}

.note {
  margin-bottom: 0;
}

.home-shell {
  min-height: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 20px);
  align-content: start;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: clamp(18px, 3vw, 28px);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-black), #3b3b3b);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.dashboard-hero h1 {
  font-size: clamp(2rem, 5vw, 3.8rem);
}

.dashboard-hero .eyebrow {
  color: #fff;
}

.dashboard-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.dashboard-stat {
  display: grid;
  gap: 4px;
  min-height: 142px;
  padding: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.dashboard-stat:hover,
.dashboard-action:hover,
.dashboard-list a:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.dashboard-stat .material-symbols-outlined {
  color: var(--accent);
  font-size: 2rem;
}

.dashboard-stat small,
.dashboard-stat em,
.dashboard-action small,
.dashboard-list small,
.dashboard-mini-stats span {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.dashboard-stat strong {
  margin-top: auto;
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  line-height: 1.05;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.dashboard-action {
  display: grid;
  gap: 6px;
  align-content: center;
  min-height: 132px;
  padding: 16px;
  color: #fff;
  border-radius: 12px;
  box-shadow: var(--touch-shadow);
}

.dashboard-action .material-symbols-outlined {
  font-size: 2.8rem;
}

.dashboard-action-icon {
  display: inline-grid;
  width: fit-content;
}

.dashboard-action-icon.stack-icon {
  position: relative;
}

.dashboard-action-icon.stack-icon > .material-symbols-outlined:first-child {
  font-size: 2.8rem;
}

.dashboard-action-icon .plus-badge {
  position: absolute;
  right: -10px;
  top: -10px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1.35rem;
  line-height: 1;
}

.dashboard-action strong {
  font-size: 1.08rem;
  line-height: 1.1;
}

.dashboard-action small {
  color: inherit;
  opacity: 0.86;
}

.action-red {
  background: var(--accent);
}

.action-dark {
  background: var(--brand-black);
}

.action-blue {
  background: #126cbd;
}

.action-green {
  color: #111;
  background: var(--brand-green);
}

.action-gray {
  background: #555f58;
}

.action-mail {
  color: #111;
  background: #f2d64b;
}

.dashboard-lower {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 18px;
}

.dashboard-panel {
  min-height: 220px;
}

.dashboard-panel h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dashboard-list {
  display: grid;
  gap: 8px;
}

.dashboard-list a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-list span,
.dashboard-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-list span,
.dashboard-list strong,
.dashboard-mini-stats strong {
  font-weight: 900;
}

.dashboard-list strong {
  text-align: right;
  white-space: nowrap;
}

.dashboard-mini-stats {
  display: grid;
  gap: 10px;
}

.dashboard-mini-stats div {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-mini-stats strong {
  font-size: 1.25rem;
}

.action-tile {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  min-height: clamp(140px, 22vw, 210px);
  padding: clamp(16px, 3vw, 28px);
  color: #fff;
  border-radius: 12px;
  box-shadow: var(--touch-shadow);
  overflow: hidden;
  touch-action: manipulation;
}

.action-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.action-tile:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.tile-icon,
.tile-label {
  position: relative;
  z-index: 1;
}

.tile-icon {
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 1;
  font-weight: 900;
}

.material-symbols-outlined.tile-icon {
  font-family: "Material Symbols Outlined", "Segoe UI Symbol", sans-serif;
  font-variation-settings: "FILL" 0, "wght" 600, "GRAD" 0, "opsz" 48;
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined", "Segoe UI Symbol", sans-serif;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  vertical-align: middle;
  font-variation-settings: "FILL" 0, "wght" 600, "GRAD" 0, "opsz" 32;
}

.button-icon,
.section-icon,
.form-icon {
  flex: 0 0 auto;
}

.button-icon {
  margin-right: 6px;
  font-size: 1.35rem;
}

.section-heading,
.page-title-icon,
.label-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  color: var(--accent);
  font-size: 1.55rem;
}

.page-title-icon .section-icon {
  font-size: 0.85em;
}

.form-icon {
  color: var(--accent);
  font-size: 1.2rem;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 8px;
  font-weight: 900;
}

.icon-link:hover {
  text-decoration: none;
}

.upload-type-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-type-hints span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.tile-label {
  font-size: clamp(1.1rem, 2.4vw, 1.8rem);
  font-weight: 900;
}

.tile-invoice {
  background: #d60000;
}

.tile-customer {
  background: #202020;
}

.tile-cash {
  background: #333333;
}

.tile-tax {
  background: #47ed60;
  color: #111;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.month-tile,
.panel,
.summary-box,
.content-section,
.doc-item,
.export-list > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.month-tile {
  display: grid;
  gap: 10px;
  min-height: 148px;
  padding: 20px;
  color: var(--text);
  box-shadow: var(--shadow);
}

.month-tile:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.month-name {
  font-size: 1.35rem;
  font-weight: 800;
}

.month-count {
  color: var(--muted);
}

.month-tile strong {
  align-self: end;
  font-size: 1.25rem;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.panel,
.content-section {
  padding: 20px;
  box-shadow: var(--shadow);
}

.content-section {
  margin-top: 24px;
}

.content-section.flush-top {
  margin-top: 0;
}

.form-card {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.customer-form-card {
  width: min(1120px, 100%);
  padding: clamp(16px, 2vw, 24px);
}

.customer-create-form {
  gap: 14px;
}

.customer-main-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.customer-address-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.customer-upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  gap: 14px;
  align-items: stretch;
}

.compact-stack {
  gap: 10px;
}

.inline-panel {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.dropzone {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 150px;
  padding: 22px;
  color: var(--text);
  text-align: center;
  background: var(--surface-soft);
  border: 2px dashed var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: #fff0f0;
}

.dropzone .material-symbols-outlined {
  color: var(--accent);
  font-size: 2.8rem;
}

.dropzone small {
  color: var(--muted);
  font-weight: 800;
}

.dropzone input {
  max-width: 280px;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.camera-button input {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-title {
  margin-bottom: 10px;
}

.summary-box {
  padding: 18px;
}

.summary-box span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-box strong {
  display: block;
  margin-top: 8px;
  font-size: 1.4rem;
}

.summary-box.accent {
  background: var(--surface-soft);
  border-color: #a7cbc5;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: var(--surface);
}

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

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.table-action {
  font-weight: 700;
}

.customers-table {
  font-size: 1.08rem;
}

.customers-table th {
  font-size: 0.9rem;
}

.cashbook-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.cashbook-table-wrap {
  overflow: visible;
}

.cashbook-table {
  min-width: 0;
  table-layout: fixed;
  font-size: 1.04rem;
}

.cashbook-table th,
.cashbook-table td {
  padding: 12px;
  overflow-wrap: anywhere;
}

.cashbook-table th:nth-child(1) {
  width: 92px;
}

.cashbook-table th:nth-child(3) {
  width: 118px;
}

.cashbook-table th:nth-child(2) {
  width: 24%;
}

.cashbook-table th:nth-child(4),
.cashbook-table th:nth-child(5),
.cashbook-table th:nth-child(6) {
  width: 128px;
  text-align: right;
}

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

.negative-amount {
  color: var(--accent-strong);
  font-weight: 900;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.inline-form.compact {
  align-items: end;
  justify-content: center;
}

.calendar-show-button {
  min-height: 52px;
  min-width: 120px;
  background: #126cbd;
  border-color: #126cbd;
}

.calendar-show-button:hover {
  background: #0b5aa0;
  border-color: #0b5aa0;
}

.cashbook-filter-form {
  align-items: end;
}

.cashbook-filter-form button {
  margin-top: auto;
}

.icon-only {
  width: 52px;
  min-width: 52px;
  padding: 0;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 900;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.calendar-legend .material-symbols-outlined {
  font-size: 1.25rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--line);
}

.legend-dot.invoice {
  background: var(--accent);
}

.legend-dot.bank {
  background: #126cbd;
}

.legend-dot.cash {
  background: #087f5b;
}

.legend-dot.holiday {
  background: #f59f00;
}

.invoice-calendar {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  background: var(--brand-black);
  color: #fff;
  font-weight: 900;
}

.calendar-weekdays div {
  padding: 10px;
  text-align: center;
}

.calendar-day {
  min-height: 142px;
  padding: 10px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day.outside {
  color: #9aa1a6;
  background: #f3f3f3;
}

.calendar-day.weekend {
  background: #f7f7f7;
}

.calendar-day.holiday {
  background: #fff7e6;
}

.calendar-day.today {
  box-shadow: inset 0 0 0 3px rgba(214, 0, 0, 0.18);
}

.calendar-date {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-date strong {
  font-size: 1.1rem;
}

.calendar-date span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-align: right;
}

.calendar-events {
  display: grid;
  gap: 6px;
}

.calendar-events:has(.calendar-more:not([open])) .extra-event {
  display: none;
}

.calendar-more {
  order: 999;
}

.calendar-more summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  color: var(--accent-strong);
  background: #fff;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.calendar-more summary::-webkit-details-marker {
  display: none;
}

.calendar-more[open] summary {
  margin-top: 2px;
}

.calendar-event {
  display: grid;
  gap: 2px;
  align-items: start;
  padding: 6px 7px;
  color: var(--text);
  border-radius: 8px;
  border-left: 4px solid var(--line);
  background: #f7f7f7;
  min-height: 44px;
}

.calendar-event:hover {
  text-decoration: none;
  filter: brightness(0.98);
}

.calendar-event .material-symbols-outlined {
  font-size: 1.05rem;
}

.calendar-event strong {
  font-size: 0.82rem;
  text-align: left;
  white-space: nowrap;
}

.event-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.15;
}

.event-invoice {
  grid-template-columns: minmax(0, 1fr);
}

.event-bank,
.event-cash {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.event-bank strong,
.event-cash strong {
  text-align: right;
}

.event-main {
  display: grid;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.25;
}

.event-main span,
.event-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-main small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.event-invoice {
  border-left-color: var(--accent);
  background: #fff0f0;
}

.event-bank {
  border-left-color: #126cbd;
  background: #eaf4ff;
}

.event-cash {
  border-left-color: #087f5b;
  background: #e9f8f2;
}

.month-bottom-summary {
  margin-top: 20px;
}

.empty {
  color: var(--muted);
  padding: 16px 0;
}

.flash {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  font-weight: 900;
}

.flash.success {
  color: #102513;
  background: #b8f7c2;
  border: 1px solid var(--brand-green);
}

.flash.error {
  color: #7f1d1d;
  background: #fee2e2;
  border: 1px solid #ef4444;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.invoice-data-group {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.invoice-data-group:first-of-type {
  margin-top: 0;
}

.invoice-data-group h3 {
  margin: 0;
  color: var(--accent-strong);
  font-size: clamp(1.18rem, 2.6vw, 1.5rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: uppercase;
  padding: 0 0 8px;
  border-bottom: 3px solid var(--accent);
}

.autocomplete-field {
  position: relative;
  display: block;
}

.vehicle-data-grid {
  align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.vehicle-form-field {
  display: grid;
  grid-template-rows: auto 52px 18px;
  gap: 6px;
  height: 100%;
}

.vehicle-form-field input,
.vehicle-form-field .autocomplete-field {
  min-height: 52px;
}

.vehicle-form-field .autocomplete-field input {
  height: 52px;
}

.autocomplete-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: grid;
  gap: 4px;
  max-height: 280px;
  padding: 6px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18);
}

.autocomplete-option {
  display: block;
  width: 100%;
  justify-content: flex-start;
  min-height: 50px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  background: #fff;
  border: 1px solid transparent;
}

.autocomplete-option:hover,
.autocomplete-option:focus {
  color: var(--text);
  background: #f3f6f8;
  border-color: var(--line);
}

.autocomplete-option strong,
.autocomplete-option span {
  display: block;
}

.autocomplete-option span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.more-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.more-toggle {
  min-width: 150px;
  min-height: 56px;
  font-size: 1.05rem;
}

.more-fields {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.more-fields[hidden],
[hidden] {
  display: none !important;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea,
button,
.button {
  min-height: 52px;
  border-radius: 8px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 1.05rem;
}

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

input.is-valid {
  border-color: #0f8a5f;
  box-shadow: 0 0 0 3px rgba(15, 138, 95, 0.14);
}

input.is-warning {
  border-color: #bf650d;
}

.field-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  min-height: 18px;
  line-height: 18px;
}

.field-hint-space {
  visibility: hidden;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.button-form {
  display: inline-flex;
  margin: 0;
}

.button-form button {
  width: 100%;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

button.danger,
.button.danger {
  background: #7f1d1d;
  border-color: #7f1d1d;
}

button.danger:hover,
.button.danger:hover {
  background: #5f1414;
  border-color: #5f1414;
}

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

.button.secondary:hover {
  background: #edf1f5;
}

.button.secondary.more-toggle {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(214, 0, 0, 0.18);
}

.button.secondary.more-toggle:hover {
  background: var(--accent-strong);
}

.button.small {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.add-position-row {
  justify-content: flex-end;
}

.add-position-button {
  width: 60px;
  min-width: 60px;
  min-height: 60px;
  border-radius: 999px;
  padding: 0;
  font-size: 2.35rem;
  font-weight: 500;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.add-position-button span {
  display: block;
  line-height: 1;
  transform: translateY(-2px);
}

.remove-position-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  color: #fff;
  background: var(--brand-black);
  border-color: var(--brand-black);
  border-radius: 999px;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
}

.remove-position-button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.invoice-live-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.invoice-live-totals div {
  display: grid;
  justify-items: start;
  gap: 4px;
}

.invoice-live-totals span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.invoice-live-totals strong {
  font-size: 1.15rem;
  text-align: left;
}

.invoice-live-total strong {
  color: var(--accent-strong);
  font-size: 1.28rem;
}

.button.large-action,
.primary-save {
  min-height: 62px;
  min-width: 180px;
  font-size: 1.12rem;
}

.touch-form {
  gap: 18px;
}

.invoice-form {
  display: grid;
  gap: 24px;
}

.editable-table input {
  min-width: 120px;
}

.suggestion-row td {
  border-top: 2px dashed #9ca3af;
  border-bottom: 2px dashed #9ca3af;
  background: #fbfcfd;
}

.suggestion-row td:first-child {
  border-left: 2px dashed #9ca3af;
}

.suggestion-row td:last-child {
  border-right: 2px dashed #9ca3af;
}

.row-form {
  display: grid;
  grid-template-columns: 1fr 2fr 0.8fr 0.9fr auto;
  gap: 10px;
  margin-top: 16px;
}

.invoice-preview[hidden] {
  display: none;
}

.preview-sheet {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-sheet > div,
.preview-items > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.preview-items {
  display: grid;
  gap: 8px;
}

.preview-item {
  display: grid !important;
  grid-template-columns: minmax(58px, 0.7fr) minmax(120px, 2fr) minmax(48px, 0.5fr) minmax(84px, 0.8fr) minmax(90px, 0.9fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.preview-meta {
  color: var(--muted);
}

.preview-sums {
  display: grid !important;
  grid-template-columns: 1fr auto;
  justify-content: end;
  gap: 8px 18px;
  padding-top: 8px;
}

.preview-total {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 1.15rem;
}

.pdf-preview-sheet {
  display: grid;
  gap: 14px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 6px solid var(--accent);
  border-radius: 8px;
}

.pdf-preview-head,
.pdf-preview-meta,
.pdf-preview-address {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pdf-preview-head img {
  max-width: 150px;
  max-height: 70px;
  object-fit: contain;
}

.pdf-preview-head strong {
  display: block;
  color: var(--accent);
  font-size: 1.2rem;
}

.form-popup-backdrop[hidden] {
  display: none;
}

.form-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.35);
}

.form-popup {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--touch-shadow);
}

.form-popup.warning {
  border-color: #f2b705;
}

.form-popup p {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.form-popup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.check-cell {
  text-align: center;
}

.check-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  color: var(--text);
}

.check-label input {
  width: 24px;
  min-height: 24px;
}

.sticky-actions {
  position: sticky;
  bottom: 12px;
  z-index: 8;
  padding: 12px;
  background: rgba(246, 247, 249, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.edit-upload-grid {
  margin-top: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.doc-item {
  display: grid;
  gap: 6px;
  padding: 14px;
  color: var(--text);
}

.doc-item:hover {
  border-color: var(--link);
  text-decoration: none;
}

.doc-item span,
.export-list span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.doc-item small {
  color: var(--muted);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.doc-item strong,
.export-list strong {
  overflow-wrap: anywhere;
}

.export-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.export-list > div {
  display: grid;
  gap: 8px;
  padding: 18px;
  background: var(--surface-soft);
}

.export-action {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.export-filter-form {
  align-items: end;
}

.export-filter-form button {
  min-height: 52px;
  margin-top: auto;
}

.mail-panel {
  display: grid;
  gap: 16px;
}

.mail-title {
  margin-bottom: 0;
}

.mailto-button {
  background: #1769e0;
  border-color: #1769e0;
}

.mailto-button:hover {
  background: #1559bd;
}

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

.mail-box {
  display: grid;
  gap: 6px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mail-box span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mail-box strong {
  overflow-wrap: anywhere;
}

.mail-body {
  margin: 0;
  padding: 16px;
  min-height: 260px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.attachment-actions .button {
  min-width: 180px;
}

@media (max-width: 960px) {
  .dashboard-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .page-head,
  .section-title,
  .inline-form,
  .actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
    padding: 16px;
  }

  .nav {
    width: 100%;
    gap: 12px;
  }

  .nav a {
    flex: 1 1 140px;
  }

  .calendar-toolbar {
    grid-template-columns: 1fr;
  }

  .calendar-toolbar .icon-only {
    width: 100%;
  }

  .month-grid,
  .dashboard-stats,
  .dashboard-actions,
  .dashboard-lower,
  .summary-grid,
    .doc-grid,
    .export-list,
    .mail-grid,
    .customer-main-grid,
    .customer-address-grid,
    .customer-upload-grid,
    .form-grid.two,
    .form-grid.three,
    .split-layout,
  .row-form {
    grid-template-columns: 1fr;
  }

  .month-tile {
    min-height: 120px;
  }
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .home-shell {
    min-height: auto;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  .app-header img,
  .brand-logo {
    max-width: 160px;
    max-height: 56px;
  }

  .action-tile {
    min-height: 126px;
    border-radius: 12px;
  }

  .tile-icon {
    font-size: clamp(2.7rem, 13vw, 4.2rem);
  }

  .tile-label {
    font-size: 1.2rem;
  }

  .preview-item {
    grid-template-columns: 1fr;
  }

  .preview-sums {
    grid-template-columns: 1fr;
  }

  .invoice-live-totals {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 12px;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav a {
    justify-content: center;
    min-height: 50px;
    padding: 8px;
    text-align: center;
  }

  .attachment-actions .button,
  .mailto-button {
    width: 100%;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    background: var(--surface-soft);
  }

  .calendar-day {
    min-height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .calendar-day:nth-child(7n) {
    border-right: 1px solid var(--line);
  }

  .calendar-day.outside {
    display: none;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  table {
    min-width: 0;
    background: transparent;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
  }

  td {
    display: grid;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 40px;
    padding: 8px 0;
    border-bottom: 1px solid #edf1f5;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  td[colspan] {
    display: block;
  }

  td[colspan]::before {
    content: "";
    display: none;
  }

  .editable-table tr,
  .editable-table td {
    display: block;
  }

  .editable-table td::before {
    display: block;
    margin-bottom: 6px;
  }
}

@media (max-width: 340px) {
  .dashboard-list a {
    grid-template-columns: 1fr;
  }

  .dashboard-actions,
  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .home-shell {
    grid-template-columns: 1fr;
  }

  .action-tile {
    min-height: 112px;
    grid-template-columns: auto 1fr;
    justify-items: start;
    gap: 18px;
  }

  .tile-icon {
    font-size: 3rem;
  }

  .tile-label {
    font-size: 1.35rem;
  }

  .nav {
    grid-template-columns: 1fr;
  }
}
