:root {
  color-scheme: dark;
  --bg: #07151d;
  --bg-deep: #061119;
  --nav: #0a202a;
  --surface: #0d2833;
  --surface-2: #12323d;
  --surface-3: #173b46;
  --line: #234651;
  --line-soft: rgba(156, 189, 198, 0.13);
  --text: #f3f7f8;
  --muted: #91aab2;
  --subtle: #6f8b94;
  --teal: #28c2bf;
  --teal-strong: #16aaa9;
  --sky: #67b7e7;
  --green: #68cf86;
  --orange: #f5a55d;
  --red: #ef7580;
  --white: #ffffff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.23);
  --header-h: 68px;
  --invoice-side-panel-width: 430px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

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

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 1.8;
}

.brand-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--teal);
  color: #062129;
  font-weight: 800;
  font-size: 18px;
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: -3px;
  bottom: 4px;
  width: 41px;
  height: 10px;
  transform: rotate(-18deg);
  background: var(--sky);
  opacity: 0.92;
}

.brand-mark > span {
  position: relative;
  z-index: 1;
}

.brand-logo {
  display: block;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.brand-logo-auth {
  height: 87px;
}

.brand-logo-header {
  height: 52px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.1;
}

.brand-caption {
  margin-top: 3px;
  color: var(--subtle);
  font-size: 10px;
  font-weight: 500;
}

.auth-page {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(420px, 2fr);
  min-height: 100vh;
  background: var(--bg-deep);
}

.auth-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 100vh;
  padding: clamp(32px, 5vw, 74px);
  overflow: hidden;
  background: #0b2631;
}

.auth-visual::before,
.auth-visual::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.auth-visual::before {
  inset: 0;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(90, 168, 181, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 168, 181, 0.13) 1px, transparent 1px);
  background-size: 52px 52px;
}

.auth-visual::after {
  right: -20%;
  bottom: -28%;
  width: 75%;
  aspect-ratio: 1;
  border: 110px solid rgba(40, 194, 191, 0.08);
  border-radius: 50%;
}

.auth-brand,
.auth-message {
  position: relative;
  z-index: 1;
}

.auth-brand {
  display: flex;
  align-items: center;
  width: min(300px, 100%);
}

.auth-message {
  max-width: 720px;
  margin: auto 0;
  padding: 72px 0;
}

.auth-kicker {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.auth-message h1 {
  margin: 0;
  max-width: 18ch;
  font-size: clamp(36px, 4.4vw, 64px);
  line-height: 1.18;
  font-weight: 700;
}

.auth-message p {
  max-width: 520px;
  margin: 22px 0 0;
  color: #9ab3bb;
  font-size: 15px;
  line-height: 1.8;
}

.auth-form-side {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: center;
  justify-items: center;
  min-height: 100vh;
  padding: 36px;
  gap: 24px;
  background: #081820;
}

.auth-form-panel {
  align-self: center;
  width: min(329px, 100%);
}

.auth-form-panel.is-wide {
  width: min(434px, 100%);
}

.auth-form-panel h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.auth-intro {
  margin: 10px 0 30px;
  color: var(--muted);
  line-height: 1.65;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field + .field {
  margin-top: 17px;
}

.form-grid .field + .field {
  margin-top: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #c7d5d9;
  font-size: 12px;
  font-weight: 600;
}

.input-wrap {
  position: relative;
}

.input-wrap .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}

.field input,
.field select,
.field textarea,
.table-control {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d252f;
  color: var(--text);
  padding: 10px 12px;
}

.input-wrap input {
  padding-left: 40px;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #617c85;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.table-control:focus {
  border-color: var(--teal);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 17px 0 24px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.check-label input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--teal);
}

.text-link {
  border: 0;
  background: transparent;
  color: #b6c9cf;
  padding: 0;
  font-size: 12px;
}

.text-link:hover {
  color: var(--teal);
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#register-form .field.button-row {
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 15px;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.btn:hover:not(:disabled) {
  border-color: #3b6671;
  background: #1b4652;
}

.btn-primary {
  background: var(--teal);
  color: #062128;
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--teal);
  background: #42d3cf;
}

.btn-secondary {
  border-color: var(--line);
  background: transparent;
  color: #cfdbdf;
}

.btn-excel {
  border-color: #2f9e63;
  background: #238653;
  color: #ffffff;
}

.btn-excel:hover:not(:disabled) {
  border-color: #42bd7c;
  background: #2fa968;
}

.btn-danger {
  border-color: rgba(239, 117, 128, 0.35);
  background: rgba(239, 117, 128, 0.1);
  color: #ff9da6;
}

.btn-block {
  width: 100%;
  min-height: 46px;
}

.auth-switch {
  margin: 22px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.auth-switch .text-link {
  margin-left: 7px;
  color: var(--teal);
  font-weight: 600;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(1600px, calc(100% - 48px));
  margin: 0 auto;
  border-top: 1px solid var(--line-soft);
  padding: 22px 0 28px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.site-footer-auth {
  align-self: end;
  width: min(520px, 100%);
  margin: 0;
  padding: 18px 0 0;
}

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

.footer-identity strong {
  color: #dce9ec;
  font-size: 12px;
  font-weight: 700;
}

.footer-identity span {
  color: var(--subtle);
  font-size: 10px;
  text-align: right;
}

.footer-identity b {
  color: #bce5e8;
  font-weight: 700;
}

.site-footer address {
  margin: 0 0 8px;
  color: #8fa9b1;
  font-style: normal;
}

.footer-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
}

.footer-contact span,
.footer-contact a {
  color: var(--subtle);
  text-decoration: none;
  white-space: nowrap;
}

.footer-contact a:hover {
  color: var(--teal);
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  height: var(--header-h);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(7, 21, 29, 0.96);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) auto;
  align-items: center;
  width: min(1600px, calc(100% - 16px));
  height: 100%;
  margin: 0 auto;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.top-nav {
  display: flex;
  align-items: stretch;
  justify-content: center;
  height: 100%;
}

.nav-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  border: 0;
  background: transparent;
  color: #8da6ae;
  padding: 0 24px;
  font-size: 13px;
  font-weight: 600;
}

.nav-button::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: -1px;
  height: 2px;
  transform: scaleX(0);
  background: var(--teal);
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--text);
}

.nav-button.is-active::after {
  transform: scaleX(1);
}

.account-menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  padding: 4px 9px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
}

.agent-pill.is-online {
  border-color: #f4b83f;
  background: #f4b83f;
  color: #081820;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(244, 184, 63, 0.12);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}

.agent-pill.is-online .status-dot {
  background: #fff8df;
  box-shadow: 0 0 0 3px rgba(255, 248, 223, 0.28);
}

.status-dot.is-online {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(104, 207, 134, 0.09);
}

.account-copy {
  text-align: right;
  line-height: 1.3;
}

.account-copy strong,
.account-copy span {
  display: block;
}

.account-copy strong {
  font-size: 11px;
}

.account-copy span {
  color: var(--subtle);
  font-size: 9px;
}

.avatar-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  border-radius: 6px;
}

.subnav-wrap {
  position: sticky;
  top: var(--header-h);
  z-index: 29;
  border-bottom: 1px solid var(--line-soft);
  background: #0a1d26;
  box-shadow: 0 8px 18px rgba(2, 12, 17, 0.14);
}

.subnav {
  display: flex;
  align-items: center;
  width: min(1600px, calc(100% - 48px));
  min-height: 45px;
  margin: 0 auto;
  gap: 5px;
  overflow: hidden;
}

.subnav-button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--subtle);
  padding: 8px 13px;
  font-size: 11px;
  font-weight: 600;
}

.subnav-button:hover,
.subnav-button.is-active {
  background: var(--surface);
  color: #e9f2f4;
}

.main-content {
  width: min(1600px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-heading h1.page-title-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  max-width: 100%;
  min-height: 40px;
  border: 1px solid rgba(40, 194, 191, 0.34);
  border-radius: 5px;
  background: rgba(40, 194, 191, 0.12);
  color: #ffffff;
  padding: 5px 10px;
  margin: 0;
  font-size: 23px;
  line-height: 1.3;
  font-weight: 700;
}

.page-title-chip .sample-mark {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.page-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.heading-meta {
  color: var(--subtle);
  font-size: 11px;
}

.dashboard-date-filter {
  display: grid;
  grid-template-columns: auto minmax(150px, auto) auto minmax(150px, auto) auto;
  align-items: center;
  gap: 8px;
}

.dashboard-date-icon {
  display: inline-flex;
  align-items: center;
  color: #ffffff;
}

.dashboard-date-icon svg {
  width: 18px;
  height: 18px;
}

.dashboard-date-field {
  position: relative;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.dashboard-date-field:hover,
.dashboard-date-field:focus-within {
  border-color: var(--teal);
}

.dashboard-date-field input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.dashboard-date-separator {
  color: #ffffff;
  font-size: 12px;
}

.dashboard-date-query {
  min-height: 36px;
  padding-inline: 16px;
}

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

.stat-card {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 18px;
  background: var(--surface);
}

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

.stat-label {
  color: var(--muted);
  font-size: 11px;
}

.dashboard-title-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  width: max-content;
  max-width: 100%;
  min-height: 28px;
  border: 1px solid rgba(40, 194, 191, 0.34);
  border-radius: 5px;
  background: rgba(40, 194, 191, 0.12);
  color: #ffffff;
  padding: 5px 9px;
  font-size: 13.2px;
  font-weight: 700;
  line-height: 16px;
}

.dashboard-title-chip .sample-mark {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.dashboard-stats-grid .stat-label.is-dashboard-sample {
  color: #ffffff;
  font-size: 13.2px;
  font-weight: 700;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border-radius: 6px;
  background: rgba(40, 194, 191, 0.1);
  color: var(--teal);
}

.stat-value {
  margin-top: 13px;
  font-size: 25px;
  font-weight: 700;
}

.stat-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: var(--subtle);
  font-size: 10px;
}

.dashboard-stats-grid .stat-foot {
  color: #ffffff;
  font-size: 11px;
}

.trend-up {
  color: var(--green);
}

.trend-down {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.9fr);
  gap: 16px;
}

.section-panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  border-bottom: 1px solid var(--line-soft);
  padding: 13px 17px;
}

.panel-header > div:first-child {
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.panel-title > .dashboard-title-chip {
  flex: 0 0 auto;
}

.panel-subtitle {
  display: block;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-page .panel-subtitle {
  color: #ffffff;
  font-size: 11px;
}

.chart-wrap {
  height: 290px;
  padding: 18px 18px 12px;
}

.chart {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  height: 100%;
}

.chart-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 8px 25px 0;
  color: #67828a;
  font-size: 9px;
  text-align: right;
}

.chart-area {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  min-width: 0;
  padding-bottom: 25px;
  border-left: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background-image: linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 100% 25%;
}

.chart-column {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: min(42px, 10%);
  height: 100%;
}

.chart-bar {
  width: 70%;
  min-width: 14px;
  max-width: 32px;
  border-radius: 3px 3px 0 0;
  background: var(--teal);
  box-shadow: 0 -7px 24px rgba(40, 194, 191, 0.12);
}

.chart-column:nth-child(3n) .chart-bar {
  background: var(--sky);
}

.chart-label {
  position: absolute;
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%);
  color: var(--subtle);
  font-size: 9px;
  white-space: nowrap;
}

.rank-list {
  margin: 0;
  padding: 8px 17px 13px;
  list-style: none;
}

.rank-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 47px;
  border-bottom: 1px solid var(--line-soft);
}

.rank-item:last-child {
  border-bottom: 0;
}

.rank-number {
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.rank-company {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.rank-value {
  color: #cbd9dd;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.recent-panel {
  grid-column: 1 / -1;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 55px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 16px;
}

.search-box {
  position: relative;
  width: min(430px, 100%);
}

.search-box .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
}

.search-box input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0a2029;
  color: var(--text);
  padding: 8px 12px 8px 36px;
  font-size: 11px;
}

.data-table-wrap {
  width: 100%;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  height: 47px;
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 13px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.data-table th {
  height: 39px;
  background: #102d37;
  color: #9bb1b8;
  font-size: 9px;
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

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

.status-badge,
.confidence-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 23px;
  border-radius: 12px;
  padding: 3px 9px;
  background: rgba(103, 183, 231, 0.12);
  color: #8fcef2;
  font-size: 9px;
  font-weight: 600;
}

.status-badge.success,
.confidence-badge.high {
  background: rgba(104, 207, 134, 0.12);
  color: #91e4a8;
}

.status-badge.warning,
.confidence-badge.medium {
  background: rgba(245, 165, 93, 0.12);
  color: #ffc07f;
}

.status-badge.danger,
.confidence-badge.low {
  background: rgba(239, 117, 128, 0.12);
  color: #ff9da6;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--invoice-side-panel-width);
  gap: 0;
  min-height: 170px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface);
}

.dropzone {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 24px;
  text-align: left;
}

.dropzone.is-dragging {
  background: rgba(40, 194, 191, 0.06);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.upload-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 66px;
  flex: 0 0 auto;
  border: 1px dashed #35606b;
  border-radius: 7px;
  background: #0a2029;
  color: var(--teal);
}

.upload-symbol .icon {
  width: 28px;
  height: 28px;
}

.upload-copy {
  min-width: 0;
  margin-left: 18px;
}

.upload-copy strong,
.upload-copy span {
  display: block;
}

.upload-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.upload-copy span {
  margin-top: 7px;
  color: var(--subtle);
  font-size: 10px;
}

.upload-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  border-left: 1px solid var(--line-soft);
  padding: 22px;
}

.upload-actions .button-row {
  width: 100%;
  justify-content: flex-end;
}

.raw-company-control {
  display: grid;
  gap: 6px;
  width: 100%;
}

.raw-company-control span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.raw-company-control select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d252f;
  color: var(--text);
  padding: 7px 10px;
  font-size: 11px;
}

.item-quality-cell {
  display: grid;
  justify-items: start;
  gap: 5px;
}

.raw-match-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid rgba(40, 194, 191, 0.25);
  border-radius: 4px;
  padding: 2px 6px;
  background: rgba(40, 194, 191, 0.08);
  color: #70d9d5;
  font-size: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.raw-upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.55fr);
  gap: 16px;
  margin-bottom: 16px;
}

.raw-upload-form {
  padding: 17px;
}

.raw-file-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px dashed #35606b;
  border-radius: 6px;
  background: #0a2029;
  color: #c8d8dc;
  padding: 11px 13px;
  text-align: left;
}

.raw-file-button:hover,
.raw-file-button:focus-visible {
  border-color: var(--teal);
  color: var(--text);
}

.raw-file-button .icon {
  flex: 0 0 auto;
  color: var(--teal);
}

.raw-file-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raw-upload-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
  padding: 14px 17px 17px;
}

.raw-import-result {
  border-color: rgba(104, 207, 134, 0.28);
}

.status-list {
  display: grid;
  margin: 0;
  padding: 5px 17px 14px;
}

.status-list > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 0;
}

.status-list > div:last-child {
  border-bottom: 0;
}

.status-list dt {
  color: var(--muted);
  font-size: 9px;
}

.status-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
  text-align: right;
}

.raw-current-company {
  display: grid;
  align-content: center;
  min-height: 180px;
  padding: 24px;
}

.raw-current-company strong,
.raw-current-company span {
  overflow-wrap: anywhere;
}

.raw-current-company strong {
  color: var(--text);
  font-size: 17px;
}

.raw-current-company span {
  margin-top: 7px;
  color: var(--subtle);
  font-size: 10px;
}

.raw-history-panel {
  margin-top: 0;
}

.empty-state.compact {
  min-height: 86px;
  padding: 18px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--invoice-side-panel-width);
  gap: 16px;
  margin-top: 16px;
}

.encom-preview-panel {
  margin-top: 16px;
  border-color: rgba(40, 194, 191, 0.36);
}

.encom-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0 16px 14px;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
}

.encom-preview-grid > div {
  min-width: 0;
  padding: 13px 14px;
  background: var(--surface);
}

.encom-preview-grid span,
.encom-preview-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.encom-preview-grid span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
}

.encom-preview-grid strong {
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.encom-preview-actions {
  align-items: center;
  padding: 0 16px 16px;
}

.invoice-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  padding: 16px;
}

.invoice-fields .field + .field {
  margin-top: 0;
}

.invoice-fields .field input,
.invoice-fields .field select {
  min-height: 38px;
  font-size: 11px;
}

.invoice-fields .analysis-summary-field input {
  background: #102a34;
  color: var(--text);
  font-weight: 700;
  cursor: default;
}

.validation-list {
  margin: 0;
  padding: 7px 16px 14px;
  list-style: none;
}

.validation-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  color: #afc1c6;
  font-size: 10px;
  line-height: 1.55;
}

.validation-item:last-child {
  border-bottom: 0;
}

.validation-item .icon {
  width: 15px;
  height: 15px;
  color: var(--green);
}

.validation-item.warning .icon {
  color: var(--orange);
}

.validation-item.danger .icon {
  color: var(--red);
}

.validation-item.is-actionable {
  margin-inline: -9px;
  padding-inline: 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.validation-item.is-actionable:hover,
.validation-item.is-actionable:focus-visible {
  outline: 0;
  background: rgba(248, 195, 93, 0.1);
  color: #e6eef0;
}

.validation-item-count {
  align-self: center;
  border: 1px solid rgba(248, 195, 93, 0.35);
  border-radius: 3px;
  padding: 2px 5px;
  color: var(--orange);
  font-size: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.items-panel {
  grid-column: 1 / -1;
  min-width: 0;
}

.editable-table {
  min-width: 1480px;
}

.editable-table .item-col-select { width: 2.5%; }
.editable-table .item-col-no { width: 2.5%; }
.editable-table .item-col-part { width: 6%; }
.editable-table .item-col-rate { width: 3.5%; }
.editable-table .item-col-tariff { width: 7.5%; }
.editable-table .item-col-hs { width: 5.5%; }
.editable-table .item-col-description { width: 24%; }
.editable-table .item-col-code { width: 17%; }
.editable-table .item-col-origin { width: 3.5%; }
.editable-table .item-col-qty { width: 3.5%; }
.editable-table .item-col-unit { width: 4.5%; }
.editable-table .item-col-price { width: 6%; }
.editable-table .item-col-amount { width: 7%; }
.editable-table .item-col-confidence { width: 7%; }

.editable-table th,
.editable-table td {
  padding: 6px 4px;
  font-size: 11.5px;
}

.editable-table th {
  font-size: 10.35px;
}

.editable-table th,
.editable-table td,
.editable-table td .table-control {
  text-align: center;
}

.editable-table .item-description-heading,
.editable-table .item-description-cell,
.editable-table .item-description-cell .table-control {
  text-align: left;
}

.editable-table .item-select-cell {
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
}

.item-select-checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #2fa968;
  cursor: pointer;
}

.editable-table tr.item-row-selected {
  background: rgba(47, 169, 104, 0.075);
}

.editable-table .item-no-value {
  display: inline-block;
}

.editable-table td:last-child .item-quality-cell {
  justify-items: center;
}

.editable-table .table-control {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  padding: 5px 6px;
  font-size: 11.5px;
}

.editable-table .table-control:hover,
.editable-table .table-control:focus {
  border-color: var(--line);
  background: #0a2029;
}

.editable-table .table-control-readonly {
  color: #f8c35d;
  cursor: default;
}

.editable-table .table-control-readonly:hover,
.editable-table .table-control-readonly:focus {
  border-color: transparent;
  background: transparent;
}

.editable-table .table-control-raw {
  color: var(--text);
  cursor: default;
}

.editable-table .table-control-raw:hover,
.editable-table .table-control-raw:focus {
  border-color: transparent;
  background: transparent;
}

.editable-table .table-control-description {
  display: block;
  white-space: nowrap;
}

.editable-table .confidence-badge {
  font-size: 10.35px;
}

.editable-table .raw-match-badge {
  font-size: 9.2px;
}

.editable-table .deletable-item-row {
  cursor: context-menu;
}

.editable-table .deletable-item-row:hover {
  background: rgba(248, 195, 93, 0.055);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 32px;
  color: var(--subtle);
  text-align: center;
}

.empty-state .icon {
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
}

.empty-state strong {
  color: #b8c8cd;
  font-size: 12px;
}

.empty-state span {
  margin-top: 7px;
  font-size: 10px;
}

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

.compact-select,
.compact-input {
  height: 35px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0a2029;
  color: #c8d6da;
  padding: 6px 10px;
  font-size: 10px;
}

.admin-summary {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 10px;
}

.admin-summary strong {
  color: var(--text);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
}

.settings-form {
  padding: 18px;
}

.settings-form .button-row {
  margin-top: 20px;
}

.encom-master-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px -18px 2px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 18px;
  background: rgba(16, 53, 64, 0.38);
}

.encom-master-toolbar > div {
  display: grid;
  gap: 4px;
}

.encom-master-toolbar strong {
  font-size: 12px;
}

.encom-master-toolbar span {
  color: var(--muted);
  font-size: 10px;
}

.encom-master-toolbar span.is-error {
  color: var(--red);
}

.encom-master-warning {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  gap: 8px;
  margin: 12px 0;
  border-left: 3px solid var(--orange);
  padding: 8px 10px;
  background: rgba(255, 190, 70, 0.08);
  color: #f7cf75;
  font-size: 10px;
  line-height: 1.55;
}

.encom-master-warning .icon {
  width: 15px;
  height: 15px;
}

.security-note {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding: 15px 18px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.security-note .icon {
  width: 16px;
  height: 16px;
  color: var(--teal);
}

.connection-list {
  margin: 0;
  padding: 7px 17px 14px;
}

.connection-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 45px;
  border-bottom: 1px solid var(--line-soft);
}

.connection-list > div:last-child {
  border-bottom: 0;
}

.connection-list dt,
.connection-list dd {
  margin: 0;
  font-size: 10px;
}

.connection-list dt {
  color: var(--muted);
}

.connection-list dd {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-align: right;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-actions .btn {
  min-height: 29px;
  padding: 4px 9px;
  font-size: 9px;
}

.member-table {
  min-width: 1640px;
}

.member-table th:first-child,
.member-table td:first-child {
  width: 190px;
}

.member-table th:nth-child(2),
.member-table td:nth-child(2) {
  width: 170px;
}

.member-table th:nth-child(3),
.member-table td:nth-child(3) {
  width: 130px;
}

.member-table th:nth-child(4),
.member-table td:nth-child(4) {
  width: 110px;
}

.member-table th:nth-child(5),
.member-table td:nth-child(5) {
  width: 180px;
}

.member-table th:nth-child(6),
.member-table td:nth-child(6) {
  width: 120px;
}

.member-table th:nth-child(7),
.member-table td:nth-child(7) {
  width: 90px;
}

.member-table th:nth-child(8),
.member-table td:nth-child(8) {
  width: 135px;
}

.member-table th:nth-child(9),
.member-table td:nth-child(9),
.member-table th:nth-child(10),
.member-table td:nth-child(10) {
  width: 75px;
}

.member-table th:last-child,
.member-table td:last-child {
  width: 265px;
}

.member-id-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.member-id-cell > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-password-reset {
  flex: 0 0 auto;
  min-height: 27px !important;
  padding: 3px 7px !important;
  font-size: 8px !important;
}

.member-table .row-actions {
  flex-wrap: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 10, 14, 0.78);
}

.member-modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a2029;
  box-shadow: var(--shadow);
}

.settlement-add-button {
  min-width: 150px;
  justify-content: center;
}

.settlement-company-panel .data-table {
  min-width: 780px;
}

.settlement-company-name,
.settlement-contact {
  display: grid;
  gap: 3px;
}

.settlement-company-name span,
.settlement-contact span {
  color: var(--muted);
  font-size: 9px;
}

.settlement-company-modal {
  display: flex;
  width: min(860px, 100%);
  flex-direction: column;
  border-color: rgba(40, 194, 191, 0.32);
  background: #09212a;
}

.settlement-modal-header {
  border-top: 3px solid var(--teal);
  padding-top: 15px;
  background: #0a252f;
}

.settlement-modal-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settlement-modal-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(40, 194, 191, 0.34);
  border-radius: 6px;
  background: rgba(40, 194, 191, 0.09);
  color: var(--teal);
}

.settlement-modal-icon .icon {
  width: 19px;
  height: 19px;
}

.settlement-company-form {
  flex: 1 1 auto;
  max-height: none;
  padding: 0 20px 19px;
}

.settlement-modal-actions {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 13px 20px;
  background: #0a252f;
}

.settlement-fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 19px 0 4px;
}

.settlement-fieldset + .settlement-fieldset {
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.settlement-fieldset legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 0;
  color: #dce9eb;
  font-size: 12px;
  font-weight: 700;
}

.settlement-fieldset legend span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: rgba(40, 194, 191, 0.13);
  color: var(--teal);
  font-size: 9px;
}

.settlement-company-form .form-grid {
  gap: 14px 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line-soft);
  padding: 17px 19px;
}

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

.modal-header h2 {
  font-size: 16px;
}

.modal-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.member-edit-form {
  max-height: calc(100vh - 132px);
  overflow-y: auto;
  padding: 19px;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
}

.validation-issue-modal {
  display: flex;
  width: min(1540px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a2029;
  box-shadow: var(--shadow);
}

.validation-issue-body {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 18px;
}

.validation-issue-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 10px;
}

.validation-issue-table {
  background: #0c2832;
}

.validation-issue-table .table-control-issue {
  border-color: rgba(248, 195, 93, 0.55);
  background: rgba(248, 195, 93, 0.07);
}

.item-delete-modal {
  width: min(620px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a2029;
  box-shadow: var(--shadow);
}

.item-delete-body {
  padding: 18px 20px 20px;
}

.item-delete-body > p {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.item-delete-body > p strong {
  color: var(--text);
}

.item-delete-summary {
  display: grid;
  grid-template-columns: 72px 140px minmax(0, 1fr);
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.item-delete-summary div {
  min-width: 0;
  padding: 11px 12px;
  border-right: 1px solid var(--line-soft);
}

.item-delete-summary div:last-child {
  border-right: 0;
}

.item-delete-summary dt {
  color: var(--muted);
  font-size: 9px;
}

.item-delete-summary dd {
  overflow: hidden;
  margin: 5px 0 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-history-row {
  cursor: pointer;
}

.invoice-history-row:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.history-status-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-status-cell > .icon {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.invoice-history-modal {
  display: flex;
  width: min(1360px, 100%);
  max-height: calc(100vh - 48px);
  flex-direction: column;
}

.invoice-history-detail-body {
  min-height: 0;
  overflow-y: auto;
}

.history-detail-loading {
  min-height: 360px;
}

.history-detail-loading .icon[data-lucide="loader-circle"] {
  animation: spin 900ms linear infinite;
}

.history-detail-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.history-detail-section h3 {
  margin: 0 0 13px;
  color: #e5edef;
  font-size: 12px;
}

.history-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  gap: 14px 20px;
}

.history-detail-grid > div {
  min-width: 0;
}

.history-detail-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
}

.history-detail-grid dd {
  min-height: 20px;
  margin: 0;
  overflow-wrap: anywhere;
  color: #e1ebed;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.55;
}

.history-header-grid .history-edit-field {
  min-width: 0;
}

.history-edit-field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
}

.history-edit-field input,
.history-item-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 9px;
  background: #0b2731;
  color: #e8f1f2;
  font: inherit;
}

.history-edit-field input:focus,
.history-item-input:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 2px rgba(40, 194, 191, 0.13);
}

.history-edit-field input[readonly],
.history-item-input[readonly] {
  border-color: transparent;
  background: transparent;
  color: #d7e4e6;
}

.history-item-input {
  padding: 6px 7px;
  text-align: center;
}

.history-description-input {
  text-align: left;
}

.history-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-section-heading h3 {
  margin-bottom: 13px;
}

.history-section-heading span {
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
}

.history-detail-table {
  min-width: 1480px;
  table-layout: auto;
}

.history-detail-table th,
.history-detail-table td {
  text-align: center;
}

.history-detail-table th:nth-child(6),
.history-detail-table td:nth-child(6) {
  width: 34%;
  min-width: 320px;
  text-align: left;
}

.history-description-cell {
  white-space: normal !important;
  line-height: 1.5;
}

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

.history-detail-empty {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.history-modal-actions {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 12px 19px;
  background: #0a2029;
}

.history-modal-status {
  margin-right: auto;
  white-space: nowrap;
}

.invoice-history-modal .encom-preview-panel {
  margin: 18px 20px;
}

.analysis-save-error-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 130;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  width: min(390px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  padding: 12px 14px;
  background: #102c36;
  box-shadow: var(--shadow);
  color: #dce7e9;
  font-size: 11px;
  line-height: 1.55;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-left-color: var(--red);
}

.toast.warning {
  border-left-color: var(--orange);
}

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

@media (max-width: 1100px) {
  .auth-page {
    grid-template-columns: minmax(0, 3fr) minmax(380px, 2fr);
  }

  .header-inner {
    grid-template-columns: 190px minmax(0, 1fr) auto;
  }

  .brand-logo-header {
    height: 44px;
  }

  .brand-caption,
  .account-copy,
  .agent-pill span {
    display: none;
  }

  .nav-button {
    padding: 0 15px;
  }

  .nav-button::after {
    left: 15px;
    right: 15px;
  }

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

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

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

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

  .raw-upload-grid {
    grid-template-columns: 1fr;
  }

  .items-panel {
    grid-column: auto;
  }
}

@media (max-width: 820px) {
  :root {
    --header-h: 60px;
  }

  .auth-page {
    display: block;
  }

  .auth-visual {
    min-height: 310px;
    padding: 28px;
  }

  .brand-logo-auth {
    height: 69px;
  }

  .brand-logo-header {
    height: 34px;
  }

  .auth-message {
    padding: 46px 0 12px;
  }

  .auth-message h1 {
    max-width: 18ch;
    font-size: 33px;
  }

  .auth-message p {
    display: none;
  }

  .auth-form-side {
    min-height: calc(100vh - 310px);
    padding: 35px 22px 48px;
  }

  .top-header {
    backdrop-filter: none;
  }

  .header-inner,
  .subnav,
  .main-content,
  .site-footer {
    width: min(100% - 28px, 1600px);
  }

  .subnav {
    overflow-x: auto;
  }

  .header-inner {
    grid-template-columns: 1fr auto;
  }

  .top-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: 62px;
    justify-content: space-around;
    border-top: 1px solid var(--line);
    background: #081a22;
  }

  .nav-button {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: auto;
    min-width: 0;
    padding: 5px 3px;
    font-size: 8.5px;
  }

  .nav-button span {
    white-space: nowrap;
  }

  .nav-button::after {
    left: 30%;
    right: 30%;
    top: -1px;
    bottom: auto;
  }

  .account-menu {
    grid-column: 2;
  }

  .account-menu .agent-pill {
    display: none;
  }

  .agent-pill {
    padding: 4px 8px;
  }

  .main-content {
    padding-bottom: 92px;
  }

  .site-footer-app {
    margin-bottom: 76px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-date-filter {
    width: 100%;
  }

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

  .recent-panel {
    grid-column: auto;
  }

  .upload-panel {
    grid-template-columns: 1fr;
  }

  .upload-actions {
    min-width: 0;
    border-top: 1px solid var(--line-soft);
    border-left: 0;
  }

  .upload-actions .button-row {
    justify-content: stretch;
  }

  .upload-actions .btn {
    flex: 1;
  }

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

  .raw-current-company {
    min-height: 120px;
  }

  .modal-backdrop {
    padding: 14px;
  }

  .invoice-history-modal {
    max-height: calc(100vh - 28px);
  }

  .history-detail-grid,
  .history-validation-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
    .dashboard-date-filter {
      grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .dashboard-date-field {
      min-width: 0;
      padding-inline: 8px;
      font-size: 11px;
    }

    .dashboard-date-query {
      grid-column: 1 / -1;
      width: 100%;
    }

    .form-grid,
    .stats-grid,
    .invoice-fields,
    .encom-preview-grid {
      grid-template-columns: 1fr;
    }

    .invoice-fields .field-wide {
      grid-column: auto;
    }

  .items-panel .panel-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .items-panel .panel-header .button-row {
    flex-wrap: wrap;
    justify-content: flex-start;
    max-width: 100%;
  }

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

  .raw-upload-form .field.full {
    grid-column: auto;
  }

  .status-list > div {
    grid-template-columns: 90px minmax(0, 1fr);
  }

  .field.full {
    grid-column: auto;
  }

  .footer-identity {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .footer-identity span {
    text-align: left;
  }

  .auth-message h1 {
    font-size: 29px;
  }

  .brand-logo-auth {
    height: 60px;
  }

  .brand-logo-header {
    height: 30px;
  }

  .brand-caption,
  .brand-text .brand-name {
    display: none;
  }

  .app-brand {
    gap: 0;
  }

  .subnav {
    overflow-x: auto;
  }

  .subnav-button {
    flex: 0 0 auto;
  }

  .page-heading h1 {
    font-size: 20px;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .filter-row > * {
    width: 100%;
  }

  .dropzone {
    align-items: flex-start;
    padding: 20px;
  }

  .upload-symbol {
    width: 50px;
    height: 50px;
  }

  .upload-copy strong {
    white-space: normal;
  }

  .upload-actions {
    padding: 16px;
  }

  .upload-actions .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .upload-actions .btn:first-child {
    grid-column: 1 / -1;
  }
}
/* Invoice OCR failures stay visible and never masquerade as extracted data. */
.analysis-error-panel { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: start; gap: 13px; margin-top: 16px; border-color: rgba(239, 117, 128, 0.35); padding: 17px; background: rgba(239, 117, 128, 0.055); }
.analysis-error-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 6px; background: rgba(239, 117, 128, 0.12); color: var(--red); }
.analysis-error-panel strong { display: block; color: #ffd3d7; font-size: 12px; }
.analysis-error-panel p { margin: 6px 0 0; color: #b7c8cd; font-size: 11px; line-height: 1.6; }
.analysis-error-panel code { display: inline-block; margin-top: 9px; color: #ff9da6; font-family: Consolas, monospace; font-size: 10px; }

.analysis-error-panel.analysis-save-error-panel {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
}

.invoice-encom-button,
.analysis-save-retry {
  width: 126px;
  min-width: 126px;
  min-height: 40px;
}

.analysis-save-retry {
  justify-self: end;
}

/* Invoice learning */
.learning-library {
  overflow: hidden;
}

.learning-profile-head,
.learning-profile-row {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 110px 64px 72px 82px 104px;
  align-items: center;
  gap: 12px;
}

.learning-profile-head {
  min-width: 850px;
  padding: 11px 16px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.learning-profile-list {
  min-width: 850px;
}

.learning-profile-row {
  width: 100%;
  min-height: 68px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.learning-profile-row:hover,
.learning-profile-row.is-active {
  background: rgba(45, 193, 196, 0.08);
}

.learning-profile-row.is-active {
  box-shadow: inset 3px 0 0 var(--cyan);
}

.learning-profile-main,
.learning-profile-main span {
  display: block;
  min-width: 0;
}

.learning-profile-main strong,
.learning-profile-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learning-profile-main strong {
  margin-bottom: 5px;
  font-size: 12px;
}

.learning-profile-main span,
.learning-profile-row > span:not(.learning-profile-main) {
  color: var(--muted);
  font-size: 10px;
}

.learning-profile-code {
  font-family: Consolas, monospace;
  color: var(--cyan) !important;
}

.learning-workspace {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.learning-workspace-header,
.learning-meta-grid,
.learning-file-bar,
.learning-items-section,
.learning-actions {
  padding: 16px;
}

.learning-meta-grid {
  display: grid;
  grid-template-columns: 150px repeat(3, minmax(0, 1fr));
  gap: 14px;
  border-top: 1px solid var(--line-soft);
}

.learning-meta-grid .field + .field {
  margin-top: 0;
}

.learning-file-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-top: 1px solid var(--line-soft);
}

.learning-file-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px dashed #2d6874;
  border-radius: 6px;
  color: var(--text);
  background: rgba(4, 31, 40, 0.45);
  text-align: left;
  cursor: pointer;
}

.learning-file-button:hover,
.learning-file-button.is-dragging {
  border-color: var(--cyan);
  background: rgba(45, 193, 196, 0.08);
}

.learning-file-button svg {
  flex: 0 0 auto;
  color: var(--cyan);
}

.learning-file-button span {
  display: block;
  min-width: 0;
}

.learning-file-button strong,
.learning-file-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learning-file-button small {
  margin-top: 4px;
  color: var(--muted);
}

.learning-review-split {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(420px, 0.9fr);
  min-height: 620px;
  border-top: 1px solid var(--line-soft);
}

.learning-preview,
.learning-corrector {
  min-width: 0;
  padding: 16px;
}

.learning-preview {
  border-right: 1px solid var(--line-soft);
}

.learning-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 12px;
}

.learning-section-title strong {
  font-size: 12px;
}

.learning-preview object,
.learning-preview img {
  display: block;
  width: 100%;
  height: 550px;
  border: 1px solid var(--line-soft);
  background: #eef2f4;
  object-fit: contain;
}

.learning-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  height: 550px;
  color: var(--muted);
  border: 1px dashed var(--line);
}

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

.learning-header-grid .field + .field {
  margin-top: 0;
}

.learning-header-field label {
  display: flex;
  min-height: 17px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.learning-header-field label small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--green);
  font-size: 8px;
  font-weight: 600;
  white-space: nowrap;
}

.learning-header-field label small .icon {
  width: 11px;
  height: 11px;
}

.learning-header-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.learning-header-control input {
  min-width: 0;
}

.learning-header-change {
  min-width: 74px;
  justify-content: center;
}

.learning-header-field.is-source-selected input {
  border-color: rgba(76, 218, 151, 0.42);
  background: rgba(76, 218, 151, 0.045);
}

.learning-header-picker-modal {
  display: flex;
  width: min(820px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  flex-direction: column;
  border: 1px solid rgba(45, 193, 196, 0.34);
  border-radius: 7px;
  background: #09212a;
  box-shadow: var(--shadow);
}

.learning-header-picker-body {
  display: flex;
  min-height: 0;
  padding: 16px 18px 18px;
  flex: 1 1 auto;
  flex-direction: column;
}

.learning-picker-current {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  min-height: 43px;
  margin-bottom: 12px;
  border-left: 3px solid var(--cyan);
  padding: 8px 12px;
  background: rgba(45, 193, 196, 0.06);
}

.learning-picker-current span {
  color: var(--muted);
  font-size: 9px;
}

.learning-picker-current strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learning-candidate-search {
  width: 100%;
  margin-bottom: 12px;
}

.learning-candidate-list {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: 520px;
  overflow-y: auto;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.learning-candidate-row {
  display: grid;
  width: 100%;
  min-height: 54px;
  grid-template-columns: minmax(0, 1fr) 190px 22px;
  align-items: center;
  gap: 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  padding: 9px 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.learning-candidate-row:last-child {
  border-bottom: 0;
}

.learning-candidate-row:hover,
.learning-candidate-row:focus-visible {
  outline: 0;
  background: rgba(45, 193, 196, 0.09);
}

.learning-candidate-row.is-selected {
  background: rgba(76, 218, 151, 0.08);
}

.learning-candidate-text {
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.45;
}

.learning-candidate-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 9px;
}

.learning-candidate-meta strong {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 600;
}

.learning-candidate-row > .icon {
  width: 16px;
  color: var(--cyan);
}

.learning-candidate-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  font-size: 10px;
}

.learning-header-picker-body .modal-actions {
  margin-top: 14px;
}

.learning-items-section {
  border-top: 1px solid var(--line-soft);
}

.learning-items-table {
  min-width: 1280px;
  table-layout: fixed;
}

.learning-items-table .learning-no { width: 54px; }
.learning-items-table .learning-part { width: 135px; }
.learning-items-table .learning-description { width: 360px; }
.learning-items-table .learning-hs { width: 94px; }
.learning-items-table .learning-origin { width: 74px; }
.learning-items-table .learning-number { width: 105px; }
.learning-items-table .learning-unit { width: 72px; }
.learning-items-table .learning-delete { width: 50px; }

.learning-description-cell .table-control {
  text-align: left;
}

.learning-validation {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  border-top: 1px solid var(--line-soft);
  border-left: 3px solid var(--orange);
  background: rgba(255, 190, 73, 0.04);
}

.learning-validation.is-passed {
  border-left-color: var(--green);
  background: rgba(76, 218, 151, 0.04);
}

.learning-validation > div strong,
.learning-validation > div span {
  display: block;
}

.learning-validation > div span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.learning-validation > div small {
  display: block;
  margin-top: 9px;
  color: #ffcf75;
  font-size: 10px;
  line-height: 1.5;
}

.learning-validation ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.learning-validation li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: #c9d8dc;
  font-size: 10px;
  line-height: 1.5;
}

.learning-validation li svg {
  flex: 0 0 auto;
  width: 14px;
  color: var(--orange);
}

.learning-validation.is-passed li svg {
  color: var(--green);
}

.learning-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--line-soft);
}

.learning-empty-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 104px;
  margin-top: 16px;
  padding: 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.learning-empty-band > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.learning-empty-band svg {
  color: var(--cyan);
}

.learning-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-top: 1px solid rgba(239, 117, 128, 0.28);
  color: #ffc9cf;
  background: rgba(239, 117, 128, 0.05);
  font-size: 11px;
}

.learning-error span,
.learning-error strong {
  display: block;
}

.learning-error strong {
  margin-bottom: 4px;
}

@media (max-width: 1100px) {
  .learning-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .learning-review-split {
    grid-template-columns: 1fr;
  }

  .learning-preview {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
}

@media (max-width: 560px) {
  .learning-profile-head {
    display: none;
  }

  .learning-profile-list {
    min-width: 0;
  }

  .learning-profile-row {
    grid-template-columns: minmax(0, 1fr) auto;
    min-width: 0;
  }

  .learning-profile-row > span:nth-child(2),
  .learning-profile-row > span:nth-child(3),
  .learning-profile-row > span:nth-child(4),
  .learning-profile-row > span:nth-child(5) {
    display: none;
  }

  .learning-meta-grid,
  .learning-header-grid,
  .learning-validation,
  .learning-validation ul {
    grid-template-columns: 1fr;
  }

  .learning-file-bar {
    grid-template-columns: 1fr;
  }

  .learning-review-split {
    min-height: 0;
  }

  .learning-preview object,
  .learning-preview img,
  .learning-preview-empty {
    height: 420px;
  }

  .learning-actions,
  .learning-empty-band {
    align-items: stretch;
    flex-direction: column;
  }

  .learning-actions .btn,
  .learning-empty-band .btn {
    width: 100%;
  }

  .learning-header-control {
    grid-template-columns: minmax(0, 1fr) 70px;
  }

  .learning-header-change {
    min-width: 0;
    padding-inline: 8px;
  }

  .learning-header-picker-modal {
    max-height: calc(100vh - 24px);
  }

  .learning-candidate-row {
    grid-template-columns: minmax(0, 1fr) 20px;
    gap: 9px;
  }

  .learning-candidate-meta {
    grid-column: 1;
  }

  .learning-candidate-row > .icon {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}
