@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

:root {
  font-family: 'DM Sans', 'Noto Sans KR', sans-serif;
  color: #172235;
  background: #f3f6fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --muted: #718096;
  --line: #e5eaf1;
  --blue: #2563eb;
  --navy: #10243d;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.topbar { min-height: 80px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--navy); text-decoration: none; }
.brand-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; color: white; background: var(--blue); font-weight: 700; box-shadow: 0 8px 20px #2563eb35; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .1em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.account { display: flex; align-items: center; gap: 12px; color: #4b5870; font-size: 13px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; color: #132238; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.04em; }
h2 { margin: 0; font-size: 18px; }
.muted { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 10px; font-weight: 700; letter-spacing: .17em; }
.login-card { width: min(440px, 100%); margin: 9vh auto; padding: 34px; border: 1px solid var(--line); border-radius: 19px; background: white; box-shadow: 0 18px 60px #1e3a5f0d; }
.login-card > .muted { margin-bottom: 24px; }
.form-stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #42516a; font-size: 12px; font-weight: 600; }
input { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid #dce3ed; border-radius: 9px; color: #172235; background: white; outline: none; }
input:focus { border-color: #6e9bff; box-shadow: 0 0 0 3px #2563eb19; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-size: 12px; font-weight: 700; transition: transform .15s, filter .15s; }
.button:hover { filter: brightness(.97); transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid #93b4ff; outline-offset: 2px; }
.button-primary { color: white; background: var(--blue); box-shadow: 0 5px 14px #2563eb2b; }
.button-secondary { color: #214bb4; border-color: #ccdaf8; background: #edf3ff; }
.button-quiet { min-height: 34px; color: #52627a; border-color: var(--line); background: white; }
.error { min-height: 18px; margin: 10px 0 0; color: #c03945; font-size: 12px; }
#app-view { padding: 36px 0 30px; }
.welcome { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.welcome .muted { margin-bottom: 0; }
.welcome > .button { min-height: 46px; white-space: nowrap; }
.notice { display: grid; gap: 5px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid #d9e6ff; border-radius: 12px; color: #52627a; background: #edf4ff; font-size: 12px; line-height: 1.55; }
.notice strong { color: #214bb4; }
.category-nav { display: flex; gap: 8px; margin: 0 0 18px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.category-button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 8px; color: #637188; background: transparent; font-size: 12px; font-weight: 700; }
.category-button:hover { color: #214bb4; background: #f3f6fb; }
.category-button.active { color: white; background: var(--blue); box-shadow: 0 4px 12px #2563eb2b; }
.category-button:focus-visible { outline: 3px solid #93b4ff; outline-offset: 2px; }
.marketplace-nav { display: flex; gap: 8px; margin: -7px 0 18px; padding: 6px; border: 1px solid #dfe7f3; border-radius: 12px; background: #eaf0f9; }
.marketplace-button { min-height: 36px; padding: 0 14px; border: 0; border-radius: 8px; color: #53647d; background: transparent; font-size: 12px; font-weight: 700; }
.marketplace-button:hover { color: #214bb4; background: #f7f9fc; }
.marketplace-button.active { color: #1d4ed8; background: white; box-shadow: 0 2px 8px #18324d14; }
.marketplace-button:focus-visible { outline: 3px solid #93b4ff; outline-offset: 2px; }
.category-hidden { display: none !important; }
.panel { margin-bottom: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 7px 24px #18324d08; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.section-heading .muted { margin-top: 6px; }
.settings-panel { border-color: #d9e6ff; }
.settings-form { display: grid; gap: 18px; }
.settings-group { padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: #fcfdff; }
.settings-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.settings-group-heading h3 { margin: 0; font-size: 14px; }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.clear-setting { display: flex; align-items: center; gap: 6px; color: #a24b53; font-size: 10px; font-weight: 500; }
.clear-setting input { width: 14px; min-height: 14px; margin: 0; accent-color: #b94c57; }
.settings-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.settings-actions .muted { margin: 0; }
.connection-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.connection { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: #3e4d62; font-size: 12px; }
.status-chip { padding: 5px 8px; border-radius: 20px; color: #a26312; background: #fff5df; font-size: 10px; font-weight: 700; white-space: nowrap; }
.status-chip.ready { color: #14805e; background: #e7f8f1; }
.mapping-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 10px; margin-bottom: 17px; }
.user-form { grid-template-columns: 1fr 1fr auto; }
.shipping-fee-form select { width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid #dce3ed; border-radius: 9px; color: #172235; background: white; font: inherit; font-size: 12px; }
.settlement-filter { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; align-items: end; gap: 10px; margin-bottom: 14px; }
.settlement-filter select, .settlement-filter input { width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid #dce3ed; border-radius: 9px; font: inherit; font-size: 12px; background: white; }
.settlement-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.settlement-total { padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fcfdff; }
.settlement-total span { display: block; color: var(--muted); font-size: 11px; }
.settlement-total strong { display: block; margin-top: 4px; font-size: 17px; }
.settlement-subheading { margin: 22px 0 10px; font-size: 14px; }
td.amount, th.amount { text-align: right; }
.template-form { display: grid; grid-template-columns: 1fr 1.5fr 1fr .7fr auto; align-items: end; gap: 10px; margin-bottom: 17px; }
.shipment-excel-form { display: grid; grid-template-columns: 1fr 1.5fr auto; align-items: end; gap: 10px; margin-bottom: 12px; }
.shipment-settings-form { grid-template-columns: 1fr 1.5fr 1fr .7fr 1fr; }
.shipment-excel-form select, .shipment-settings-form select { width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid #dce3ed; border-radius: 9px; color: #172235; background: white; font: inherit; font-size: 12px; }
.shipment-excel-form input[type="file"], .shipment-settings-form input[type="file"] { min-height: 42px; padding: 8px; font-size: 11px; }
.shipment-settings-form > .button, .shipment-settings-form .error, .shipment-settings-form .template-field-mappings { grid-column: 1 / -1; }
.sender-info-heading { margin-top: 24px; }
.sender-info-heading h3 { margin: 0; font-size: 15px; }
.vendor-sender-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 10px; margin-bottom: 17px; }
.template-form .error, .template-field-mappings, #save-template-button { grid-column: 1 / -1; }
.template-field-mappings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdff; }
.template-field-mappings h3, .template-field-mappings p { grid-column: 1 / -1; margin: 0; }
.template-header-choice { color: var(--muted); font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
th { padding: 10px 11px; color: #78869b; background: #f7f9fc; font-size: 10px; font-weight: 700; white-space: nowrap; }
td { padding: 11px; border-top: 1px solid #edf0f5; color: #3e4d62; vertical-align: top; }
td small { color: var(--muted); }
.remove-button { border: 0; color: #b34f57; background: transparent; font-size: 11px; }
.download-link { color: var(--blue); font-weight: 600; text-decoration: none; white-space: nowrap; }
.dispatch-actions { min-width: 160px; }
.dispatch-actions .button { display: block; min-height: 32px; margin: 0 0 5px; padding: 0 9px; font-size: 10px; white-space: nowrap; }
.shipment-input { width: 100%; min-width: 130px; min-height: 36px; margin-bottom: 5px; padding: 6px 8px; border: 1px solid #dce3ed; border-radius: 8px; color: #172235; background: white; font: inherit; font-size: 11px; }
.shipment-actions { min-width: 150px; }
.shipment-actions small, #shipment-email-rows td small { display: block; margin: 0 0 7px; color: var(--muted); font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.shipment-actions .button { min-height: 34px; padding: 0 9px; font-size: 10px; white-space: nowrap; }
.button-approve { color: white; background: #17815f; }
.button-cancel { color: #8a4250; border-color: #f0dce0; background: #fff7f8; }
.empty-row { padding: 18px 11px; color: #8a96a8; text-align: center; }
.results-panel { border-color: #d9e6ff; }
.results-panel ul { display: grid; gap: 8px; padding-left: 20px; color: #4e5c72; font-size: 12px; }
.result-summary { margin-bottom: 12px; color: #4e5c72; font-size: 13px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 2; max-width: min(440px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 10px; color: white; background: #172b46; box-shadow: 0 8px 28px #0f233540; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s; }
.toast.visible { opacity: 1; transform: translateY(0); }
footer { padding: 14px 0 24px; color: #8994a5; text-align: center; font-size: 10px; }
@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 620px); }
  .topbar { min-height: 68px; }
  .brand small { font-size: 9px; }
  #app-view { padding-top: 25px; }
  .welcome { align-items: stretch; flex-direction: column; }
  .welcome > .button { width: 100%; }
  .category-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-button { padding: 0 8px; }
  .marketplace-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .marketplace-button { padding: 0 8px; }
  .connection-list { grid-template-columns: 1fr; }
  .mapping-form, .user-form, .template-form, .vendor-sender-form, .shipment-excel-form, .settlement-filter, .settlement-totals { grid-template-columns: 1fr; }
  .template-field-mappings { grid-template-columns: 1fr; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-group-heading, .settings-actions { align-items: stretch; flex-direction: column; }
  .panel { padding: 15px; }
  .login-card { margin-top: 6vh; padding: 25px; }
}
