:root {
  --bg: #f6f7f7;
  --surface: #ffffff;
  --surface-soft: #f9faf9;
  --ink: #172123;
  --muted: #667174;
  --placeholder: #9aa4a6;
  --line: #d9dfdf;
  --line-soft: #e9eeee;
  --action: #0f6b66;
  --action-2: #174447;
  --amber: #9a5b12;
  --red: #a63636;
  --green: #28734f;
  --blue: #26566b;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.45 "Segoe UI", "Aptos", system-ui, sans-serif;
  overflow-x: hidden;
}

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

.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;
}

button,
.button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 11px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  white-space: nowrap;
}

button:hover,
.button:hover { border-color: #aab7b8; text-decoration: none; }

.compact {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 107, 102, .22);
  outline-offset: 1px;
}

.primary {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
  font-weight: 650;
}

.secondary {
  background: var(--action-2);
  border-color: var(--action-2);
  color: #fff;
  font-weight: 650;
}

.danger {
  border-color: #e2b8b8;
  color: var(--red);
  background: #fff7f7;
  font-weight: 650;
}

.danger:hover {
  border-color: var(--red);
  background: #fff0f0;
}

.ghost { background: transparent; }
.muted { color: var(--muted); font-size: 12px; }
.strongish { font-weight: 650; }
.nowrap { white-space: nowrap; }
.truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 11px;
  margin: 0 0 4px;
}

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 8px 9px;
  font: inherit;
}

textarea { resize: vertical; }

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

.filter-form input::placeholder {
  color: #a8b0b2;
}

.alert {
  border: 1px solid #e3b7b7;
  background: #fff4f4;
  color: var(--red);
  padding: 10px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(23,33,35,.05) 1px, transparent 1px),
    linear-gradient(rgba(23,33,35,.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 50px rgba(23, 33, 35, .10);
}

.login-panel h1 { margin: 0 0 20px; font-size: 28px; }
.stack { display: grid; gap: 14px; }

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.top-actions,
.scan-export,
.export-actions,
.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gmail-connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.gmail-connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 2px rgba(102, 113, 116, .12);
}

.gmail-connection.connected {
  color: var(--green);
  background: #edf7f1;
  border-color: #c4dfcf;
}

.gmail-connection.disconnected {
  color: var(--amber);
  background: #fff8ed;
  border-color: #e9ca97;
}

.gmail-connection-email {
  color: var(--muted);
  font-weight: 600;
}

.workspace {
  position: relative;
  padding: 14px 18px 30px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.filter-sidebar {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 86px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.sidebar-filter {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--line-soft);
  margin-top: 14px;
  padding-top: 14px;
}

.sidebar-filter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
}

.sidebar-filter-head h2 {
  margin: 0;
  font-size: 14px;
}

.filter-form {
  display: grid;
  gap: 0;
}

.quick-filter-stack,
.advanced-filter-grid {
  display: grid;
  gap: 10px;
}

.date-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.advanced-filter {
  border-top: 1px solid var(--line-soft);
  margin-top: 12px;
  padding-top: 10px;
}

.advanced-filter summary {
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  list-style-position: outside;
  margin-left: 14px;
}

.advanced-filter-grid { margin-top: 10px; }
.filter-actions { justify-content: space-between; margin-top: 12px; }
.filter-actions .button,
.filter-actions button { flex: 1; }

.sidebar-scan-form {
  display: grid;
  gap: 10px;
}

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

.table-column { min-width: 0; }

.table-region {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: visible;
}

.table-meta {
  position: relative;
  z-index: 5;
  min-height: 48px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.table-meta > div:first-child {
  min-width: 220px;
}

.table-meta h2 {
  margin: 0;
  font-size: 14px;
}

.table-search-form {
  display: flex;
  align-items: center;
  flex: 1 1 300px;
  max-width: 460px;
  gap: 6px;
  flex-wrap: wrap;
}

.table-search-form input {
  flex: 1;
  min-width: 160px;
}

.export-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.export-toolbar {
  display: inline-flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.export-split {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  filter: drop-shadow(0 1px 1px rgba(23, 33, 35, .12));
  z-index: 1;
}

.drive-export-form {
  display: inline-flex;
}

.drive-export-form--menu {
  display: block;
  width: 100%;
}

.drive-export-button {
  min-height: 36px;
  gap: 8px;
  border-color: #bfd5d3;
  background: #eef7f6;
  color: var(--action-2);
  font-size: 13px;
  font-weight: 750;
  filter: drop-shadow(0 1px 1px rgba(23, 33, 35, .10));
}

.drive-export-button:disabled {
  opacity: .52;
  cursor: not-allowed;
  filter: none;
}

.drive-selection-count {
  min-width: 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.export-split--open {
  z-index: 50;
}

.export-split + .export-split {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

.export-main,
.export-toggle {
  min-height: 36px;
  border: 0;
  font: inherit;
  transition: background .14s ease, border-color .14s ease, color .14s ease, filter .14s ease;
}

.export-split > form,
.export-menu-panel > form {
  margin: 0;
}

.export-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.export-main:hover { text-decoration: none; }

.export-format {
  min-width: 34px;
  padding: 1px 5px 2px;
  border-radius: 999px;
  background: rgba(23, 33, 35, .08);
  color: inherit;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}

.export-split--primary .export-main,
.export-split--primary .export-toggle {
  background: var(--action);
  color: #fff;
}

.export-split--primary .export-format {
  background: rgba(255, 255, 255, .20);
}

.export-split--excel .export-main,
.export-split--excel .export-toggle {
  background: #ffffff;
  color: #263033;
  box-shadow: inset 0 0 0 1px var(--line);
}

.export-split--excel .export-format {
  color: #276146;
  background: #e6f3eb;
}

.export-split--drive .export-main,
.export-split--drive .export-toggle {
  background: #eef7f6;
  color: var(--action-2);
  box-shadow: inset 0 0 0 1px #bfd5d3;
}

.export-split--drive .export-format {
  color: var(--action-2);
  background: #d9eeee;
}

.drive-menu-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.drive-menu-button:disabled {
  opacity: .58;
  cursor: not-allowed;
}

.export-menu {
  position: relative;
  display: inline-flex;
}

.export-toggle {
  list-style: none;
  width: 32px;
  border-left: 1px solid rgba(23, 33, 35, .14);
  border-radius: 0 var(--radius) var(--radius) 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.export-split--primary .export-toggle {
  border-left-color: rgba(255, 255, 255, .34);
}

.export-toggle::-webkit-details-marker { display: none; }

.export-toggle::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .16s ease;
}

.export-menu[open] .export-toggle::before {
  transform: translateY(2px) rotate(225deg);
}

.export-split:hover .export-main,
.export-split:hover .export-toggle,
.export-menu[open] .export-toggle {
  filter: brightness(.94);
}

.export-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 100;
  min-width: 244px;
  padding: 6px;
  border: 1px solid #33383b;
  border-radius: 7px;
  background: #202224;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .28);
}

.export-menu-panel::before {
  content: "";
  position: absolute;
  right: 11px;
  top: -4px;
  width: 8px;
  height: 8px;
  background: #202224;
  border-left: 1px solid #33383b;
  border-top: 1px solid #33383b;
  transform: rotate(45deg);
}

.export-menu-item {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #f4f5f5;
  font: inherit;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}

.export-menu-item:hover {
  background: #2b2e31;
  text-decoration: none;
}

.export-menu-icon {
  position: relative;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  color: #aeb4b8;
}

.export-menu-icon--download::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 2px;
  width: 2px;
  height: 9px;
  background: currentColor;
}

.export-menu-icon--download::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg);
}

.export-menu-icon--archive::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 4px;
  width: 12px;
  height: 10px;
  border: 1.6px solid currentColor;
  border-top-width: 4px;
  border-radius: 2px;
}

.export-menu-icon--sheet::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 10px;
  height: 14px;
  border: 1.6px solid currentColor;
  border-radius: 2px;
}

.export-menu-icon--sheet::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  width: 4px;
  height: 6px;
  border-left: 1.4px solid currentColor;
  border-right: 1.4px solid currentColor;
}

.export-menu-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.export-menu-title {
  color: #f6f7f7;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
}

.export-menu-subtitle {
  color: #92999e;
  font-size: 12px;
  line-height: 1.25;
}

.table-wrap {
  position: relative;
  z-index: 1;
  max-height: calc(100vh - 185px);
  min-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.inline-notice {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 650;
}

.inline-notice.success {
  color: var(--green);
  background: #edf7f1;
}

.inline-notice.warning {
  color: var(--amber);
  background: #fff8ed;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.invoice-table {
  min-width: 0;
  table-layout: fixed;
}

.col-select { width: 4%; }
.col-received { width: 13%; }
.col-employee { width: 18%; }
.col-vendor { width: 18%; }
.col-doc { width: 20%; }
.col-amount { width: 14%; }
.col-actions { width: 10%; }

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
  overflow: hidden;
}

th {
  background: #eef2f1;
  color: #344043;
  font-size: 12px;
  font-weight: 750;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: inset 0 -1px 0 var(--line);
}

.select-col {
  text-align: center;
  vertical-align: middle;
}

.invoice-export-checkbox,
.invoice-export-select-all {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--action);
  cursor: pointer;
}

.invoice-export-select-all:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

tbody tr.invoice-row--exported {
  background: #f1f4f3;
  font-weight: 400;
}

tbody tr.invoice-row--pending {
  background: #fbfdfc;
  font-weight: 650;
}

tbody tr.invoice-row--exported .cell-main,
tbody tr.invoice-row--exported .strongish,
tbody tr.invoice-row--exported .document-cell-title {
  font-weight: 400;
}

tbody tr:hover { background: var(--surface-soft); }
.cell-main { font-weight: 650; }
.employee-link {
  display: block;
  color: inherit;
}

.employee-link:hover .cell-main { color: var(--action); }
.num { text-align: right; white-space: nowrap; }
.subject {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.document-cell-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.document-cell-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.row-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

.row-action { display: inline-flex; }

.row-actions .compact {
  min-width: 0;
}

.file-download-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-color: #bfd5d3;
  background: var(--action-2);
  color: #d9eeee;
}

.file-download-button:hover {
  border-color: var(--action);
  background: var(--action);
}

.file-download-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.amber {
  color: var(--amber);
  background: #fff6e9;
  border-color: #e6c28b;
}

.badge.document-kind {
  color: var(--blue);
  background: #edf5f7;
  border-color: #c3dce4;
  text-transform: capitalize;
}

.status.new { color: var(--blue); background: #e8f4f7; border-color: #b8d8e1; }
.status.needs_review { color: var(--amber); background: #fff6e9; border-color: #e6c28b; }
.status.approved,
.status.exported { color: var(--green); background: #e8f5ee; border-color: #b9dcc9; }
.status.ignored { color: var(--muted); background: #f0f2f2; border-color: #d9dfdf; }

.pagination {
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  padding: 14px 18px 30px;
}

.detail-main,
.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.detail-main { padding: 18px; }

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

.record-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

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

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  padding: 0 0 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

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

.wide { grid-column: 1 / -1; }
.form-footer { display: flex; justify-content: flex-end; }

.detail-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.side-panel { padding: 14px; }
.side-panel h2 { margin: 0 0 10px; font-size: 14px; }

.side-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.side-panel-head h2 { margin: 0; }

.detail-export-actions {
  margin-bottom: 10px;
}

.detail-export-actions .export-toolbar {
  width: 100%;
  flex-direction: column;
  gap: 6px;
}

.detail-export-actions .export-split {
  width: 100%;
}

.detail-export-actions .export-main {
  flex: 1;
}

dl {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 8px;
  margin: 0;
}

dt { color: var(--muted); font-size: 12px; }
dd { margin: 0; overflow-wrap: anywhere; }

.inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.attachment {
  display: grid;
  gap: 3px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
}

.attachment:first-of-type { border-top: 0; }
.attachment span,
.attachment code { color: var(--muted); font-size: 12px; }
.attachment code { overflow-wrap: anywhere; }
.back { margin-right: 4px; color: var(--muted); }

.danger-zone {
  border-color: #e2b8b8;
}

.danger-zone form {
  display: grid;
}

.one-time-password {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #e6c28b;
  border-radius: var(--radius);
  background: #fff8ed;
}

.one-time-password code {
  padding: 8px 10px;
  border: 1px solid #e6c28b;
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.admin-metrics > div {
  display: grid;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-metrics strong {
  font-size: 20px;
  line-height: 1.1;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  align-items: start;
}

.admin-table-wrap {
  max-height: calc(100vh - 260px);
}

.admin-users-table {
  min-width: 0;
}

.audit-event {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
}

.audit-event:first-of-type { border-top: 0; }

.audit-file-details summary {
  cursor: pointer;
  color: var(--action);
  font-weight: 650;
}

.audit-file-list {
  display: grid;
  gap: 5px;
  margin: 8px 0 0;
  padding-left: 18px;
}

.audit-file-list li {
  overflow-wrap: anywhere;
}

.scan-overlay {
  position: fixed;
  inset: 58px 0 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  padding: 52px 18px 18px;
  background: rgba(246, 247, 247, .68);
  backdrop-filter: blur(3px);
}

.scan-overlay[hidden] {
  display: none;
}

.scan-loader-card {
  width: min(390px, 100%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 18px 44px rgba(23, 33, 35, .14);
}

.scan-loader-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.scan-loader-visual {
  width: 40px;
  height: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  align-items: end;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.scan-loader-visual span {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--action);
  animation: scanPulse .9s ease-in-out infinite;
}

.scan-loader-visual span:nth-child(2) { animation-delay: .12s; }
.scan-loader-visual span:nth-child(3) { animation-delay: .24s; }

.scan-loader-bar {
  grid-column: 1 / -1;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.scan-loader-bar::before {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--action);
  animation: scanSlide 1.15s ease-in-out infinite;
}

body.is-scanning .sidebar-scan-form button {
  opacity: .78;
  cursor: wait;
}

body.is-drive-exporting .drive-export-button {
  opacity: .78;
  cursor: wait;
}

@keyframes scanPulse {
  0%, 100% { height: 8px; opacity: .55; }
  50% { height: 22px; opacity: 1; }
}

@keyframes scanSlide {
  0% { transform: translateX(-105%); }
  55%, 100% { transform: translateX(245%); }
}

@media (max-width: 1180px) {
  .dashboard-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .dashboard-layout { grid-template-columns: 1fr; }

  .filter-sidebar {
    position: static;
    max-height: none;
  }

  .col-received { width: 14%; }
  .col-employee { width: 19%; }
  .col-vendor { width: 18%; }
  .col-doc { width: 20%; }
  .col-amount { width: 14%; }
  .col-actions { width: 11%; }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    padding: 12px;
    flex-direction: column;
  }

  .brand-block {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .top-actions {
    width: 100%;
  }

  .workspace,
  .detail-layout { padding: 12px; }

  .dashboard-layout,
  .admin-layout,
  .admin-metrics,
  .edit-grid,
  .inline { grid-template-columns: 1fr; }

  .filter-sidebar {
    position: static;
    max-height: none;
  }

  .filter-actions,
  .scan-export,
  .export-actions,
  .table-search-form { justify-content: stretch; }

  .filter-actions > *,
  .export-actions > *,
  .scan-export > *,
  .scan-export button,
  .scan-export .button,
  .table-search-form,
  .table-search-form input,
  .table-search-form button { width: 100%; }

  .table-search-form {
    max-width: none;
  }

  .export-toolbar {
    width: 100%;
    flex-direction: column;
    gap: 6px;
  }

  .export-split {
    width: 100%;
  }

  .drive-export-form,
  .drive-export-button {
    width: 100%;
  }

  .export-split + .export-split {
    margin-left: 0;
    margin-top: 0;
    padding-left: 0;
    padding-top: 0;
    border-left: 0;
    border-top: 0;
  }

  .export-main {
    flex: 1;
  }

  .export-menu-panel {
    width: min(244px, calc(100vw - 48px));
  }

  .table-wrap { max-height: 62vh; }
  th,
  td {
    padding: 7px 6px;
    font-size: 12px;
  }

  #invoice-table .invoice-table th:nth-child(1),
  #invoice-table .invoice-table td:nth-child(1),
  #invoice-table .invoice-table th:nth-child(6),
  #invoice-table .invoice-table td:nth-child(6) {
    display: none;
  }

  .col-employee { width: 21%; }
  .col-vendor { width: 19%; }
  .col-doc { width: 21%; }
  .col-amount { width: 15%; }
  .col-actions { width: 15%; }

  dl { grid-template-columns: 1fr; gap: 3px; }
}
