:root {
  color-scheme: light;
  font-family: Arial, "Malgun Gothic", sans-serif;
  --bg: #eef2f4;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink: #121820;
  --muted: #637080;
  --line: #d7dde3;
  --primary: #0b6f68;
  --primary-dark: #1b242d;
  --accent: #c47a16;
  --ok: #157347;
  --warn: #a65f00;
  --danger: #b42318;
  --steel: #415466;
  --shadow: 0 8px 22px rgba(18, 24, 32, .08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(108px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 16px;
  background: linear-gradient(90deg, #151c23, #20313a 52%, #28443f);
  color: #fff;
  box-shadow: 0 3px 16px rgba(18, 24, 32, .18);
}

.brand-lockup {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: #b7c2ce;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--steel);
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.15;
}

.header-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  flex: 0 0 auto;
  font-size: 12px;
  color: #c8dbe4;
}

.header-meta strong {
  color: #f6d99f;
  font-size: 12px;
}

main {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px 14px 34px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.section-head h2 {
  margin-bottom: 5px;
  font-size: 22px;
  line-height: 1.25;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.executive-head h2 {
  font-size: 24px;
}

.upload-panel,
.result,
.receipt-list,
.receipt-detail,
.summary-card,
.ops-panel,
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #b8c8d6;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.capture-button {
  position: relative;
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 86px;
  padding: 15px;
  border: 1px dashed #7db5c0;
  border-radius: 8px;
  background: #f7fbfc;
  color: var(--ink);
  overflow: hidden;
}

.capture-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.capture-button strong {
  display: block;
  font-size: 16px;
}

.capture-button small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capture-icon {
  position: relative;
  width: 48px;
  height: 38px;
  border: 3px solid var(--primary);
  border-radius: 8px;
}

.capture-icon::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 7px;
  width: 18px;
  height: 18px;
  border: 3px solid var(--primary);
  border-radius: 999px;
}

.capture-icon::after {
  content: "";
  position: absolute;
  right: 7px;
  top: -8px;
  width: 14px;
  height: 8px;
  border-radius: 6px 6px 0 0;
  background: var(--primary);
}

.primary-action {
  min-height: 50px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(15, 111, 125, .18);
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 22px;
  line-height: 1;
}

.result {
  margin-top: 14px;
  padding: 14px;
}

.result:empty {
  display: none;
}

.result-top,
.receipt-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.result h3 {
  margin: 12px 0 8px;
  font-size: 28px;
  line-height: 1.1;
}

.result-meta {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
}

.result-ok {
  margin: 12px 0 0;
  color: var(--ok);
  font-weight: 700;
}

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

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #c8dbe4;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #edf3f6;
  color: #385163;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #e2f7ea;
  color: var(--ok);
}

.badge.warn {
  background: #fff2df;
  color: var(--warn);
}

.command-center {
  display: grid;
  gap: 12px;
}

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

.kpi-card {
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 13px;
  background: linear-gradient(180deg, #fff, #f9fbfc);
}

.kpi-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi-card strong {
  font-size: clamp(22px, 7vw, 32px);
  line-height: 1.05;
}

.kpi-card small {
  align-self: end;
  color: var(--steel);
  font-size: 12px;
}

.kpi-card.focus {
  border-color: #88bdb7;
  background: linear-gradient(180deg, #ffffff, #eff8f6);
}

.kpi-card.ok {
  border-color: #a7d7bd;
}

.kpi-card.warn {
  border-color: #e7be7b;
  background: linear-gradient(180deg, #ffffff, #fff8ec);
}

.ops-grid {
  display: grid;
  gap: 12px;
}

.ops-panel {
  display: grid;
  gap: 12px;
  padding: 13px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.panel-head h3,
.panel-head h4 {
  margin: 0 0 4px;
  font-size: 17px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #edf2f5;
  color: var(--steel);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.ok {
  background: #e4f6eb;
  color: var(--ok);
}

.status-pill.warn {
  background: #fff0d8;
  color: var(--warn);
}

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

.brief-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  text-align: left;
}

.brief-row strong,
.brief-row b {
  display: block;
  font-size: 14px;
}

.brief-row small,
.brief-row em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.brief-right {
  display: grid;
  justify-items: end;
  min-width: 110px;
}

.brief-row em.medium,
.brief-row em.high {
  color: var(--warn);
  font-weight: 700;
}

.brief-row em.low {
  color: var(--steel);
}

.close-meter {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 13px;
  border-radius: 8px;
}

.close-meter strong {
  font-size: 24px;
}

.close-meter span {
  color: var(--muted);
  font-size: 13px;
}

.close-meter.ready {
  background: #e8f7ee;
  color: var(--ok);
}

.close-meter.hold {
  background: #fff5e6;
  color: var(--warn);
}

.compact-action {
  min-height: 44px;
}

.progress-row {
  display: grid;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.progress-row:first-of-type {
  border-top: 0;
}

.progress-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.progress-row span,
.progress-row small {
  color: var(--muted);
  font-size: 12px;
}

.progress-row strong {
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebef;
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.empty-state {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.empty-state.compact {
  padding: 9px;
}

.command-loading {
  padding: 18px;
}

.review-layout {
  display: grid;
  gap: 12px;
}

.receipt-list,
.receipt-detail {
  min-height: 120px;
  padding: 10px;
}

.receipt-item {
  display: grid;
  gap: 7px;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.receipt-item.attention {
  border-color: #e7be7b;
  background: #fffaf1;
}

.receipt-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.receipt-main b {
  color: var(--primary-dark);
  white-space: nowrap;
}

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

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

.detail-grid img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.document-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.document-head h3 {
  margin-bottom: 5px;
  font-size: 22px;
}

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

.integrity-grid span {
  display: grid;
  gap: 4px;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.integrity-grid b {
  font-size: 18px;
}

.integrity-grid small {
  color: var(--muted);
  font-size: 11px;
}

.amount-panel {
  display: grid;
  gap: 5px;
  margin: 12px 0;
  padding: 12px;
  border-radius: 8px;
  background: #f3f8fa;
}

.amount-panel strong {
  font-size: 24px;
}

.amount-panel span {
  color: var(--muted);
  font-size: 13px;
}

.audit-panel {
  display: grid;
  gap: 9px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.warning-list {
  margin: 0;
  padding-left: 18px;
  color: var(--warn);
  font-size: 13px;
  line-height: 1.5;
}

.edit-panel {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.edit-panel h4 {
  margin: 0;
  font-size: 16px;
}

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

.secondary-action {
  min-height: 46px;
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  border: 1px solid #7db5c0;
  font-weight: 700;
}

.edit-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.delete-panel {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #f1c3bd;
  border-radius: 8px;
  background: #fff7f6;
}

.delete-panel h4 {
  margin: 0;
  color: var(--danger);
  font-size: 16px;
}

.delete-panel p {
  margin: 0;
  color: #7a4a44;
  font-size: 13px;
  line-height: 1.45;
}

.danger-action {
  min-height: 46px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
}

.items-editor {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.table-actions {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.table-actions h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.table-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.item-rows {
  display: grid;
  gap: 10px;
}

.item-edit-row {
  display: grid;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.item-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item-row-head strong {
  font-size: 14px;
}

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

.item-editor-grid label {
  min-width: 0;
}

.item-editor-grid .wide {
  grid-column: 1 / -1;
}

.item-editor-grid input,
.item-editor-grid select {
  min-height: 42px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 14px;
}

.mini-action {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  border: 1px solid #7db5c0;
  background: #fff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.danger-mini {
  border-color: #efb4ad;
  color: var(--danger);
}

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

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 7px;
  text-align: right;
}

th:first-child,
td:first-child,
td.name {
  text-align: left;
}

.summary-grid {
  display: grid;
  gap: 12px;
}

.summary-card {
  padding: 14px;
}

.summary-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.summary-total > strong {
  display: block;
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1.1;
}

.summary-card p {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  margin: 0;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.summary-card p:first-of-type {
  border-top: 0;
}

.summary-card strong {
  color: var(--primary-dark);
}

.summary-card small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.pending-line {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #fff7eb;
  color: var(--warn);
  font-weight: 700;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(14px);
}

.nav {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 58px;
  border-radius: 8px;
  background: transparent;
  color: #5a6e7f;
  font-size: 12px;
  font-weight: 700;
}

.nav.active {
  background: #e5f3f5;
  color: var(--primary);
}

.tab-icon {
  position: relative;
  width: 22px;
  height: 22px;
}

.tab-control::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 4px;
  width: 16px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.tab-control::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 14px;
  width: 3px;
  height: 3px;
  background: currentColor;
  box-shadow: 5px -5px 0 currentColor, 10px -1px 0 currentColor;
}

.tab-upload::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 5px;
  width: 18px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.tab-upload::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 9px;
  width: 6px;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.tab-review::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 14px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.tab-review::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 8px;
  width: 7px;
  height: 4px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.tab-summary::before {
  content: "";
  position: absolute;
  left: 4px;
  bottom: 3px;
  width: 3px;
  height: 9px;
  background: currentColor;
  box-shadow: 6px -5px 0 currentColor, 12px -2px 0 currentColor;
}

@media (min-width: 760px) {
  .app-header {
    position: static;
    padding: 22px 28px;
  }

  main {
    padding: 24px 24px 128px;
  }

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

  .ops-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  }

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

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

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

  .item-editor-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .item-editor-grid .wide {
    grid-column: span 2;
  }

  .review-layout {
    grid-template-columns: minmax(280px, 360px) 1fr;
  }

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

  .tabbar {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: min(560px, calc(100% - 32px));
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
}
