@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); }

:root {
  --ink: #111418;
  --muted: #5B616E;
  --secondary: #2E333B;
  --soft: #4A505C;
  --accent: #3B5772;
  --accent-hover: #2A4157;
  --accent-tint: #EDF1F5;
  --border-card: #DADDE3;
  --border-input: #C9CDD5;
  --divider: #E6E8EC;
  --surface-info: #F4F5F7;
  --surface-input: #F7F8FA;
  --success: #1E6B45;
  --success-tint: #EAF4EE;
  --danger: #B42318;
  --danger-tint: #FDF0EF;
  --warning: #8A5A00;
  --warning-tint: #FDF6E7;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #FFFFFF;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

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

/* ---------- Layout ---------- */
.page {
  max-width: 1260px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
}

.page-narrow {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
}

.bar {
  min-height: 68px;
  padding: 10px 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--divider);
}

.bar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
}

.bar-brand:hover {
  text-decoration: none;
  color: var(--ink);
}

.bar-logo {
  height: 26px;
  width: auto;
  display: block;
}

.bar-divider {
  width: 1px;
  height: 20px;
  background: var(--divider);
}

.bar-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--secondary);
  padding: 6px 0;
  text-decoration: none;
}

.nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.container {
  flex-grow: 1;
  padding: 28px 0 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.center {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  padding: 32px 0;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.logo {
  height: auto;
  display: block;
  align-self: center;
}

.brand-sub {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer {
  padding: 18px 0 26px;
  border-top: 1px solid var(--divider);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Cards & Surfaces ---------- */
.card {
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 20px;
}

.info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-info);
  border: 1px solid var(--divider);
}

.tile {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.row > * {
  flex: 1;
  min-width: 170px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 1 auto;
}

.toolbar-actions > * {
  flex: 0 0 auto;
}

.search-form {
  margin: 0;
  width: 240px;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.date-range-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.date-filter-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.date-filter-label {
  white-space: nowrap;
}

.date-filter-field input[type="date"] {
  width: 146px;
  height: 42px;
  padding: 0 10px;
  font-size: 13.5px;
}

.date-range-clear {
  height: 42px;
  padding: 0 11px;
  font-size: 13px;
  color: var(--muted);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 240px;
}

.search-form .search-box {
  width: 100%;
}

.search-box input {
  height: 42px;
  padding-right: 34px;
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.search-clear:hover {
  background: var(--surface-info);
  color: var(--ink);
}

/* ---------- Typography Helpers ---------- */
.muted {
  color: var(--muted);
  font-size: 14px;
}

.overline {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
}

/* ---------- Forms & Controls ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-input);
  background: #FFFFFF;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

input[type="file"] {
  padding: 8px 12px;
  background: var(--surface-input);
  border-style: dashed;
}

textarea {
  height: auto;
  min-height: 96px;
  padding: 12px 14px;
  line-height: 1.45;
  resize: vertical;
}

button, .btn {
  height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border-input);
  background: #FFFFFF;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover, .btn:hover {
  background: var(--surface-input);
  color: var(--ink);
  text-decoration: none;
}

.btn-primary {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
  font-weight: 600;
}

.btn-primary:hover {
  background: #262B33;
  border-color: #262B33;
  color: #FFFFFF;
}

.btn-accent {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #FFFFFF;
}

.btn-wide {
  width: 100%;
  height: 48px;
  font-size: 15px;
}

.btn-disabled {
  opacity: 0.55;
  pointer-events: none;
  background: var(--surface-info);
}

.btn-danger {
  background: transparent;
  border-color: rgba(180, 35, 24, 0.30);
  color: var(--danger);
  font-weight: 600;
}

.btn-danger:hover {
  background: var(--danger-tint);
  color: var(--danger);
}

.btn-warning {
  background: var(--warning-tint);
  border-color: rgba(138, 90, 0, 0.30);
  color: var(--warning);
  font-weight: 600;
}

.btn-warning:hover {
  background: #FAECD2;
  color: var(--warning);
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--divider);
}

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

tbody tr:hover {
  background: var(--surface-input);
}

th {
  vertical-align: bottom;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  vertical-align: middle;
}

.col-title {
  width: 32%;
  min-width: 150px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.invoice-title-link {
  color: var(--ink);
  font-weight: 500;
}

.col-customer {
  width: 22%;
  min-width: 120px;
  overflow-wrap: break-word;
  word-break: break-word;
}

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

.cell-date {
  white-space: nowrap;
  font-size: 13px;
}

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

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

.table-actions {
  display: inline-flex;
  gap: 5px;
  justify-content: flex-end;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}

.table-actions > * {
  flex: 0 0 auto;
}

.table-actions .btn,
.table-actions button {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 7px;
  white-space: nowrap;
}

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

.pager-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.pager-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 1120px) {
  .invoices-table .table-actions {
    display: inline-grid;
    grid-template-columns: repeat(2, auto);
    justify-items: stretch;
  }
}

@media (max-width: 900px) {
  .invoices-table,
  .invoices-table tbody {
    display: block;
    width: 100%;
  }

  .invoices-table thead {
    display: none;
  }

  .invoices-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--divider);
    align-items: start;
  }

  .invoices-table tbody tr:first-child {
    padding-top: 2px;
  }

  .invoices-table tbody tr:last-child {
    padding-bottom: 2px;
    border-bottom: none;
  }

  .invoices-table td {
    display: block;
    padding: 0;
    border-bottom: none;
    width: auto !important;
    min-width: 0;
    text-align: left;
  }

  .invoices-table .cell-number {
    grid-column: 1 / 2;
    grid-row: 1;
    white-space: normal;
  }

  .invoices-table .cell-pdf {
    grid-column: 2 / 3;
    grid-row: 1;
    justify-self: end;
  }

  .invoices-table .col-title {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 15px;
  }

  .invoices-table .invoice-title-link {
    font-weight: 600;
  }

  .invoices-table .col-customer {
    grid-column: 1 / 2;
    grid-row: 3;
    font-size: 13px;
  }

  .invoices-table .cell-date {
    grid-column: 2 / 3;
    grid-row: 3;
    justify-self: end;
    text-align: right;
    font-size: 12px;
  }

  .invoices-table .cell-actions {
    grid-column: 1 / -1;
    grid-row: 4;
    padding-top: 6px;
    white-space: normal;
  }

  .invoices-table .table-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 0 14px;
  }

  .card {
    padding: 14px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-form {
    flex: 1 1 180px;
    width: auto;
  }

  .invoices-table .col-customer {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .invoices-table .cell-date {
    grid-column: 1 / -1;
    grid-row: 4;
    justify-self: start;
    text-align: left;
  }

  .invoices-table .cell-actions {
    grid-row: 5;
  }
}

/* ---------- Badges & Alerts ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.pill-storno {
  background: var(--danger-tint);
  color: var(--danger);
}

.pill-ok {
  background: var(--success-tint);
  color: var(--success);
}

.alert-error {
  border-color: rgba(180, 35, 24, 0.30);
  background: var(--danger-tint);
}

.alert-success {
  border-color: rgba(30, 107, 69, 0.30);
  background: var(--success-tint);
}

/* ---------- Rich Searchable Dropdown (Combobox) ---------- */
.combo {
  position: relative;
  width: 100%;
}

.combo-control {
  position: relative;
  display: flex;
  align-items: center;
}

.combo-input {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-input);
  background: #FFFFFF;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  cursor: text;
}

.combo.open .combo-input {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.combo-chevron {
  position: absolute;
  right: 10px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
  transition: transform 0.15s ease;
}

.combo.open .combo-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.combo-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  background: #FFFFFF;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(17, 20, 24, 0.12);
  padding: 6px;
  display: none;
}

.combo.open .combo-menu {
  display: block;
}

.combo-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.combo-option:hover,
.combo-option.active {
  background: var(--surface-input);
}

.combo-option.selected {
  background: var(--accent-tint);
}

.combo-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.combo-option-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.combo-option-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.combo-option-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-empty {
  padding: 14px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.combo-footer {
  border-top: 1px solid var(--divider);
  margin-top: 4px;
  padding: 8px 12px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
