@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans+KR:wght@400;500;600;700&family=Oswald:wght@400;500;600;700&display=swap");

:root {
  --bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --line: rgba(116, 81, 63, 0.16);
  --ink: #3f2d26;
  --muted: #8f786c;
  --blue: #c86a21;
  --blue-deep: #a3493d;
  --green: #18794e;
  --amber: #9f6508;
  --error: #b33a3a;
  --shadow: 0 18px 28px rgba(82, 60, 46, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
  color: var(--ink);
}

body {
  background: linear-gradient(180deg, #f4f7fb 0%, #e9eef5 100%);
}

.ledger-page {
  min-height: 100vh;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.page-header,
.card {
  border: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(180deg, #fffefb, #fcfaf6);
  box-shadow: var(--shadow);
}

.page-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.page-header h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.home-link,
.ghost-link,
button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 254, 0.98);
  color: #a3493d;
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
}

button,
.ghost-link {
  cursor: pointer;
}

.home-link:hover,
.ghost-link:hover {
  background: #a3493d;
  border-color: #a3493d;
  color: #fff7f0;
}

.primary {
  background: linear-gradient(180deg, var(--blue), var(--blue-deep));
  border-color: var(--blue-deep);
  color: #fff;
}

.secondary {
  background: linear-gradient(180deg, #2250a5, #173d82);
}

.danger {
  background: linear-gradient(180deg, #c33f32, #8f251e);
  border-color: #8f251e;
  color: #fff;
}

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

.card {
  padding: 16px;
  display: grid;
  gap: 14px;
}

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

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.ledger-db-refresh-warning {
  align-self: end;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(179, 58, 58, 0.28);
  background: rgba(255, 244, 242, 0.94);
  color: var(--error);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

.ledger-db-refresh-warning[hidden],
.ledger-db-refresh-warning:empty {
  display: none !important;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  border: 1px solid rgba(24, 34, 48, 0.14);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
}

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

.status-chip {
  border: 1px solid rgba(24, 34, 48, 0.08);
  border-radius: 18px;
  background: #fff;
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.status-chip span,
.muted-text {
  color: var(--muted);
}

.customer-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}

[hidden] {
  display: none !important;
}

.client-list-manager {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.client-list-manager-head,
.saved-client-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.saved-client-lists,
.client-list-form {
  display: grid;
  gap: 10px;
}

.saved-client-list {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fcfaf6;
}

.saved-client-list-details {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.saved-client-list-details small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.saved-client-list .inline-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.client-list-form {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.client-list-options {
  max-height: 250px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.client-list-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.client-list-option input {
  flex: none;
}

.client-tabs {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(89, 73, 55, 0.16);
  background: rgba(255, 255, 255, 0.36);
}

.client-tab {
  min-width: 132px;
  border: 0 !important;
  border-right: 1px solid rgba(89, 73, 55, 0.16) !important;
  background: transparent !important;
  color: rgba(22, 20, 17, 0.66) !important;
}

.client-tab:last-child {
  border-right: 0 !important;
}

.client-tab.is-active {
  background: #f18f01 !important;
  color: #fffaf1 !important;
}

.client-list {
  max-height: 360px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-right: 4px;
}

.client-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(24, 34, 48, 0.08);
  border-radius: 14px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  min-height: 42px;
  justify-content: flex-start;
}

.client-item.is-hidden,
.is-hidden {
  display: none !important;
}

.client-item.is-excluded {
  background: #f18f01 !important;
  border-color: #f18f01 !important;
  color: #fffaf1 !important;
  box-shadow: inset 0 0 0 2px rgba(255, 250, 241, 0.58) !important;
  font-weight: 900 !important;
}

.client-item.is-excluded:hover {
  background: #d97900 !important;
  border-color: #d97900 !important;
  color: #fffaf1 !important;
}

.status-box {
  min-height: 52px;
  border: 1px solid rgba(31, 114, 218, 0.14);
  border-radius: 18px;
  background: rgba(31, 114, 218, 0.06);
  padding: 14px 16px;
  color: #275f9e;
  line-height: 1.7;
}

.status-box.is-success {
  border-color: rgba(24, 121, 78, 0.16);
  background: rgba(24, 121, 78, 0.08);
  color: var(--green);
}

.status-box.is-error {
  border-color: rgba(179, 58, 58, 0.18);
  background: rgba(179, 58, 58, 0.08);
  color: var(--error);
}

.status-box.is-warning {
  border-color: rgba(159, 101, 8, 0.16);
  background: rgba(159, 101, 8, 0.08);
  color: var(--amber);
}

.download-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.latest-ledger-card {
  border: 1px solid rgba(24, 34, 48, 0.08);
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.latest-ledger-card h3 {
  margin: 0;
  font-size: 16px;
}

.latest-ledger-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.latest-ledger-type {
  font-weight: 800;
  color: var(--blue-deep);
}

.latest-ledger-meta {
  min-width: 0;
  color: var(--muted);
}

.latest-ledger-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 700;
}

.result-summary {
  margin: 0;
  border: 1px solid rgba(24, 34, 48, 0.08);
  border-radius: 18px;
  background: #fff;
  padding: 16px;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.8;
}

.result-summary:empty {
  display: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(24, 34, 48, 0.08);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  line-height: 1.6;
}

thead th {
  background: #edf3fb;
  position: sticky;
  top: 0;
}

@media (max-width: 1080px) {
  .control-grid,
  .file-grid,
  .client-list,
  .client-list-options {
    grid-template-columns: 1fr;
  }
}

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

  .page-header,
  .card {
    border-radius: 20px;
  }

  .page-header,
  .section-head,
  .customer-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .inline-actions,
  .download-strip {
    flex-direction: column;
  }

  .client-list-manager-head,
  .saved-client-list {
    align-items: stretch;
    flex-direction: column;
  }

  .latest-ledger-files {
    grid-template-columns: 1fr;
  }

  .latest-ledger-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .latest-ledger-row .ghost-link {
    grid-column: 2;
    width: fit-content;
  }
}

/* v8 editorial portfolio override */
html,
body {
  font-family: "IBM Plex Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
}

body {
  background: linear-gradient(180deg, #f4f7fb 0%, #e9eef5 100%);
  color: #3a2c25;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.58;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.3) 0 15%, transparent 15% 100%),
    linear-gradient(-18deg, rgba(255, 255, 255, 0.2) 0 12%, transparent 12% 100%);
}

.ledger-page {
  position: relative;
  width: min(1520px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 14px 24px;
  gap: 12px;
}

.page-header,
.card {
  border: 1px solid rgba(116, 81, 63, 0.16);
  border-radius: 0;
  background: linear-gradient(180deg, #fffefb, #fcfaf6);
  box-shadow: 0 16px 28px rgba(82, 60, 46, 0.12);
}

.page-header {
  padding: 18px 18px 16px;
  align-items: flex-end;
}

.page-header h1,
.section-head h2 {
  font-family: "Oswald", "IBM Plex Sans KR", "Malgun Gothic", sans-serif;
  color: #f18f01;
  letter-spacing: -0.02em;
  font-weight: 600;
}

#template-status {
  color: rgba(79, 71, 64, 0.72) !important;
}

.page-header h1 {
  font-size: clamp(30px, 3.3vw, 46px);
  line-height: 0.92;
}

.section-head h2 {
  font-size: clamp(20px, 1.7vw, 28px);
  line-height: 0.96;
}

.home-link,
.ghost-link,
button,
.primary,
.secondary {
  border: 1px solid rgba(192, 88, 72, 0.32);
  border-radius: 0;
  background: #fcfaf6;
  color: #f18f01;
  padding: 10px 14px;
  box-shadow: none;
  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

button:hover:not(:disabled),
.home-link:hover,
.ghost-link:hover {
  background: #f18f01;
  color: #f7eee4;
  border-color: #f18f01;
  transform: translateY(-2px);
}

.field span,
.status-chip span,
.muted-text {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: #9c6f5a;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
  border: 1px solid rgba(116, 81, 63, 0.18);
  border-radius: 0;
  background: rgba(255, 255, 254, 0.96);
  color: #3a2c25;
  padding: 10px 12px;
  font-size: 13px;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
select:focus {
  outline: none;
  border-color: rgba(192, 88, 72, 0.48);
  box-shadow: 0 0 0 3px rgba(192, 88, 72, 0.08);
}

input[type="file"]::file-selector-button {
  border: 1px solid rgba(192, 88, 72, 0.24);
  border-radius: 0;
  background: #fcfaf6;
  color: #f18f01;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

input[type="file"]::file-selector-button:hover {
  background: #f18f01;
  color: #f7eee4;
}

.status-chip,
.client-item,
.result-summary {
  border-radius: 0;
  background: rgba(255, 255, 254, 0.95);
}

.status-box {
  border: 1px solid rgba(192, 88, 72, 0.16);
  border-radius: 0;
  background: rgba(192, 88, 72, 0.08);
  color: #a24c40;
  padding: 12px 14px;
  font-size: 12px;
}

.status-box.is-success {
  border-color: rgba(63, 122, 74, 0.2);
  background: rgba(63, 122, 74, 0.08);
  color: #3f7a4a;
}

.status-box.is-error {
  border-color: rgba(174, 75, 65, 0.2);
  background: rgba(174, 75, 65, 0.08);
  color: #ae4b41;
}

.status-box.is-warning {
  border-color: rgba(168, 117, 33, 0.18);
  background: rgba(168, 117, 33, 0.08);
  color: #a87521;
}

thead th {
  background: #ead8c4;
  color: #8c463c;
}

th,
td {
  font-size: 13px;
}

@media (max-width: 720px) {
  .page-header {
    display: flex;
    grid-template-columns: none;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .page-header .home-link {
    width: auto;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1;
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* Ledger final orange/cream alignment */
body {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.22), transparent 24%),
    linear-gradient(180deg, #c2c2c2 0%, #b6b6b6 100%) !important;
  color: #161411 !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 100%);
  background-size: 110px 110px;
}

.ledger-page {
  position: relative;
  width: min(1460px, calc(100vw - 28px)) !important;
  margin: 0 auto;
  padding: 14px !important;
  gap: 10px !important;
}

.page-header,
.card {
  border: 1px solid rgba(89, 73, 55, 0.22) !important;
  border-radius: 0 !important;
  background: linear-gradient(180deg, #ffffff, #f9fbfd) !important;
  box-shadow: 0 16px 28px rgba(82, 60, 46, 0.12) !important;
}

.page-header {
  position: relative;
  padding: 24px 16px 14px !important;
  align-items: flex-end !important;
}

.page-header::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  height: 1px;
  background: rgba(241, 143, 1, 0.34);
}

.page-header h1 {
  font-family: "IBM Plex Sans KR", "Helvetica Neue", Arial, sans-serif !important;
  color: #f18f01 !important;
  letter-spacing: -0.02em !important;
  font-weight: 600 !important;
}

.page-header h1 {
  font-size: clamp(24px, 3vw, 36px) !important;
  line-height: 1.02 !important;
}

.section-head h2 {
  font-size: clamp(18px, 1.5vw, 24px) !important;
  line-height: 1.02 !important;
  font-family: "IBM Plex Sans KR", "Helvetica Neue", Arial, sans-serif !important;
  color: #5f5650 !important;
  letter-spacing: -0.02em !important;
  font-weight: 600 !important;
}

.home-link,
.ghost-link,
button,
.primary,
.secondary {
  border: 1px solid rgba(241, 143, 1, 0.32) !important;
  border-radius: 0 !important;
  background: rgba(255, 255, 254, 0.98) !important;
  color: #f18f01 !important;
  box-shadow: none !important;
}

button:hover:not(:disabled),
.home-link:hover,
.ghost-link:hover {
  background: #f18f01 !important;
  color: #fffaf1 !important;
  border-color: #f18f01 !important;
  transform: translateY(-1px);
}

.primary {
  background: #f18f01 !important;
  border-color: #f18f01 !important;
  color: #fffaf1 !important;
}

.secondary {
  background: rgba(255, 255, 254, 0.98) !important;
  color: #f18f01 !important;
}

.field span,
.status-chip span,
.muted-text {
  color: rgba(22, 20, 17, 0.58) !important;
  font-family: "IBM Plex Mono", monospace !important;
  font-size: 11px !important;
  letter-spacing: 0.05em !important;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
  border: 1px solid rgba(89, 73, 55, 0.18) !important;
  border-radius: 0 !important;
  background: rgba(255, 255, 255, 0.66) !important;
  color: #161411 !important;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
select:focus {
  border-color: rgba(241, 143, 1, 0.48) !important;
  box-shadow: 0 0 0 3px rgba(241, 143, 1, 0.08) !important;
}

input[type="file"]::file-selector-button {
  border: 1px solid rgba(241, 143, 1, 0.24) !important;
  border-radius: 0 !important;
  background: rgba(255, 255, 254, 0.98) !important;
  color: #f18f01 !important;
}

.status-chip,
.client-item,
.result-summary {
  border-radius: 0 !important;
  background: rgba(255, 255, 255, 0.42) !important;
  border: 1px solid rgba(89, 73, 55, 0.16) !important;
}

.status-box {
  border: 1px solid rgba(241, 143, 1, 0.16) !important;
  border-radius: 0 !important;
  background: rgba(241, 143, 1, 0.08) !important;
  color: #a56a10 !important;
}

thead th {
  background: rgba(241, 143, 1, 0.07) !important;
  color: rgba(22, 20, 17, 0.62) !important;
  font-family: "IBM Plex Mono", monospace !important;
}

th,
td {
  border-bottom: 1px solid rgba(89, 73, 55, 0.12) !important;
}

.ledger-control-row {
  grid-template-columns: minmax(260px, 1.2fr) minmax(170px, 0.7fr) minmax(130px, 0.55fr) auto !important;
  align-items: center;
}

.field-inline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.field-inline span {
  font-family: "IBM Plex Sans KR", "Malgun Gothic", sans-serif !important;
  font-size: 16px !important;
  font-weight: 800 !important;
  letter-spacing: 0 !important;
  color: rgba(22, 20, 17, 0.72) !important;
  white-space: nowrap;
}

.ledger-control-row input,
.ledger-control-row select {
  min-height: 42px;
  font-size: 15px !important;
}

.ledger-control-row button {
  min-height: 42px;
  align-self: stretch;
}

.ledger-data-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ledger-data-item {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid rgba(89, 73, 55, 0.16);
  background: rgba(255, 255, 255, 0.42);
}

.ledger-data-item span {
  color: rgba(22, 20, 17, 0.62);
  font-size: 13px;
  font-weight: 800;
}

.ledger-data-item strong {
  color: rgba(22, 20, 17, 0.5);
  font-size: 18px;
  font-weight: 900;
}

.ledger-data-item strong.is-success {
  color: #3f7a4a;
}

.ledger-data-item strong.is-warning {
  color: #a87521;
}

.ledger-data-item strong.is-error {
  color: #ae4b41;
}

.ledger-progress {
  position: relative;
  height: 14px;
  overflow: hidden;
  border: 1px solid rgba(241, 143, 1, 0.24);
  background: rgba(255, 255, 255, 0.52);
}

.ledger-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, rgba(241, 143, 1, 0.56), rgba(241, 143, 1, 0.92));
  transition: width 0.35s ease;
}

.ledger-progress.is-running::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.58), transparent);
  animation: ledger-progress-sheen 1.15s linear infinite;
}

@keyframes ledger-progress-sheen {
  to {
    transform: translateX(100%);
  }
}

@media (max-width: 1080px) {
  .ledger-control-row {
    grid-template-columns: 1fr !important;
  }

  .ledger-data-status {
    grid-template-columns: 1fr;
  }
}
