:root {
  --green-900: #123722;
  --green-800: #18522f;
  --green-700: #12843b;
  --green-600: #16a34a;
  --green-100: #eefaf2;
  --line: #dfe9e2;
  --soft: #f7faf8;
  --red: #dc2626;
  --text: #142018;
  --muted: #66756d;
  --shadow: 0 14px 32px rgba(18, 55, 34, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
  font-size: 15px;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 18px;
  color: #fff;
  background: var(--green-600);
  font-weight: 800;
  cursor: pointer;
}

button:hover { background: var(--green-700); }
button.secondary { background: var(--green-800); }
button.danger { background: var(--red); }
button.ghost {
  color: var(--green-800);
  background: #fff;
  border: 1px solid var(--line);
}

input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid #cfd9d3;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

textarea { min-height: 120px; resize: vertical; }
label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 800; }

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 40px 18px;
}

.login-card {
  width: min(510px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--green-800);
  background: var(--green-100);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.field { margin-bottom: 16px; }
.check-line,
.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 800;
}

.check-line input,
.switch-line input {
  width: auto;
  min-height: auto;
}

.error { margin-top: 12px; color: var(--red); font-weight: 800; }
.success { color: var(--green-700); font-weight: 800; }

.app-shell { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 72px;
  padding: 0 28px;
  background: linear-gradient(100deg, #122b1c, #20623a);
  color: #fff;
}

.brand {
  min-width: 220px;
  font-size: 24px;
  font-weight: 950;
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255,255,255,.78);
}

.nav {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.nav button {
  min-height: auto;
  padding: 0 18px;
  border-radius: 0;
  color: #fff;
  background: transparent;
  font-size: 15px;
  font-weight: 900;
}

.nav button + button { border-left: 1px solid rgba(255,255,255,.32); }
.nav button.active { color: #fff; text-decoration: underline; text-decoration-color: #ff9aae; text-underline-offset: 10px; text-decoration-thickness: 3px; }
.nav button:hover { color: #ffd4dd; }

.user-strip {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 20px;
  font-weight: 900;
}

.user-strip span:last-child {
  align-self: center;
  color: #38443d;
  font-size: 13px;
  font-weight: 700;
}

.page {
  padding: 0 24px 36px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 12px;
  font-size: 18px;
  font-weight: 950;
}

.section-title::before {
  content: "";
  width: 7px;
  height: 22px;
  border-radius: 99px;
  background: linear-gradient(var(--red) 0 45%, var(--green-600) 45% 100%);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(340px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.dashboard-grid > .panel {
  min-width: 0;
}

.shipment-dashboard-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr);
}

.shipment-filter-panel,
.notice-panel {
  min-width: 0;
}

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

.shipment-filters,
.admin-filters,
.client-filters {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filters .wide { grid-column: 1 / -1; }

.filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.filter-actions button {
  width: 100%;
  min-height: 44px;
}

.notice-list {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.notice-panel {
  display: flex;
  flex-direction: column;
}

.notice-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  cursor: pointer;
}

.notice-card h3 { margin: 0 0 6px; font-size: 16px; }
.notice-card p { margin: 0; color: var(--muted); font-size: 13px; }

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.toolbar select { width: auto; min-width: 92px; }
.toolbar button { min-height: 36px; padding: 0 14px; font-size: 13px; }

.settlement-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.settlement-summary article {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(18, 55, 34, 0.05);
}

.settlement-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settlement-summary strong {
  display: block;
  margin-top: 6px;
  color: var(--green-800);
  font-size: 22px;
  font-weight: 950;
}

.settlement-summary .negative strong,
.settlement-negative {
  color: var(--red);
}

.settlement-positive {
  color: var(--green-800);
}

.settlement-filter-panel {
  margin-bottom: 14px;
}

.settlement-monthly-panel {
  margin-bottom: 14px;
}

.settlement-monthly-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.settlement-monthly-head h2 {
  margin: 0;
  font-size: 18px;
}

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

.settlement-month-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.settlement-month-controls label {
  margin: 0 0 4px;
}

.settlement-month-controls select {
  width: auto;
  min-width: 96px;
  min-height: 36px;
  padding: 7px 10px;
}

.settlement-month-range {
  display: inline-block;
  margin-top: 4px;
}

.settlement-monthly-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.settlement-monthly-table {
  min-width: 820px;
}

.settlement-monthly-table th,
.settlement-monthly-table td {
  text-align: right;
}

.settlement-monthly-table th:first-child,
.settlement-monthly-table th:nth-child(2),
.settlement-monthly-table td:first-child,
.settlement-monthly-table td:nth-child(2) {
  text-align: left;
}

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

.settlement-table-wrap table {
  min-width: 1900px;
}

.settlement-money-input {
  min-width: 118px;
  text-align: right;
}

.settlement-status-select {
  min-width: 130px;
}

.settlement-memo-input {
  min-width: 210px;
  text-align: left;
}

.bulk-edit-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 29, 18, .42);
}

.bulk-edit-panel {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(12, 29, 18, .24);
}

.shipment-bulk-edit-panel {
  width: min(880px, 100%);
}

.bulk-edit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.bulk-edit-head h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.bulk-edit-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

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

.bulk-edit-section {
  padding-top: 2px;
}

.bulk-edit-section + .bulk-edit-section {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.bulk-edit-section h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--brand);
}

.bulk-edit-row {
  display: grid;
  gap: 12px;
}

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

.bulk-edit-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.bulk-edit-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-top: 18px;
}

.box-edit-panel {
  width: min(980px, 100%);
}

.domestic-edit-panel {
  width: min(560px, 100%);
}

.domestic-edit-grid {
  display: grid;
  gap: 14px;
}

.domestic-edit-grid textarea {
  min-height: 150px;
  line-height: 1.5;
}

.shipment-edit-panel {
  width: min(1040px, 100%);
}

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

.shipment-edit-field {
  min-width: 0;
}

.shipment-edit-field label {
  margin-bottom: 6px;
}

.shipment-edit-panel .table-input,
.shipment-edit-panel .email-tax-edit .table-input {
  width: 100%;
  min-width: 0;
}

.shipment-edit-panel .email-tax-edit {
  display: grid;
  gap: 8px;
}

.shipment-edit-textarea {
  min-height: 76px;
  line-height: 1.45;
}

.shipment-edit-readonly {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 800;
}

.shipment-edit-documents .document-actions {
  justify-content: flex-start;
}

.shipment-edit-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.box-edit-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.box-edit-tools button {
  min-height: 36px;
}

.box-edit-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.box-edit-table {
  min-width: 820px;
}

.box-edit-table th,
.box-edit-table td {
  text-align: center;
}

.box-edit-table input {
  min-width: 96px;
  text-align: right;
}

.box-calculated {
  color: var(--green-800);
  font-weight: 950;
}

.box-edit-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.box-edit-summary span {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.box-edit-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--green-800);
  font-size: 18px;
  font-weight: 950;
}

.box-count {
  margin-top: 4px;
  color: var(--green-700);
  font-size: 11px;
  font-weight: 950;
}

.box-value-list {
  display: flex;
  flex-direction: column;
  min-width: 42px;
  margin: -11px -10px;
}

.box-value-list span {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 10px;
  color: inherit;
  font: inherit;
  line-height: inherit;
}

.box-value-list span + span {
  border-top: 1px solid var(--line);
}

.domestic-shipping-cell {
  display: grid;
  gap: 4px;
  min-width: 96px;
  line-height: 1.35;
  justify-items: center;
}

.domestic-shipping-cell em {
  display: inline-flex;
  justify-self: center;
  width: max-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e6f7ee;
  color: var(--green-800);
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
}

.domestic-shipping-cell strong {
  color: var(--green-800);
  font-size: 12px;
}

.domestic-tracking-list {
  display: grid;
  gap: 2px;
  max-width: 112px;
}

.domestic-tracking-list span {
  display: block;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
}

.domestic-tracking-list .tracking-more {
  color: var(--green-800);
  font-size: 11px;
  font-weight: 900;
}

.domestic-shipping-same em {
  background: #eef5f1;
  color: var(--muted);
}

.domestic-shipping-edit {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.domestic-group-cell {
  background: #f0faf4;
  box-shadow: inset 2px 0 0 #a7d9ba;
  vertical-align: middle;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  border-bottom: 0;
}

.table-scrollbar {
  position: sticky;
  bottom: 58px;
  z-index: 13;
  width: 100%;
  height: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
}

.table-scrollbar > div {
  height: 1px;
}

.table-scrollbar::-webkit-scrollbar {
  height: 12px;
}

.table-scrollbar::-webkit-scrollbar-track {
  background: #eef5ef;
  border-radius: 999px;
}

.table-scrollbar::-webkit-scrollbar-thumb {
  background: #9ca39e;
  border-radius: 999px;
}

.pagination {
  position: sticky;
  bottom: 0;
  z-index: 12;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pagination > div {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pagination button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--green-800);
  border: 1px solid var(--line);
  box-shadow: none;
}

.pagination button:hover,
.pagination button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.page-refresh-flash {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(19, 91, 48, 0.96);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(10, 40, 24, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.page-refresh-flash.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

table {
  width: 100%;
  min-width: 1500px;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--green-100);
  font-weight: 900;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover td {
  background: #f4fbf7;
}

.shipment-item-parent td {
  border-bottom-color: #eaf4ed;
}

.shipment-item-row td {
  background: #fbfdfb;
  color: #244133;
}

.shipment-item-row:hover td {
  background: #f4fbf7;
}

.editing-row td {
  background: #fbfffc;
  vertical-align: middle;
}

.editing-row:hover td {
  background: #fbfffc;
}

.settlement-complete-row td,
.settlement-complete-row:hover td {
  background: #e8f6ff;
}

.settlement-complete-row .table-input {
  background: #f7fcff;
  border-color: #a9d8ee;
}

.table-input {
  min-width: 92px;
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 13px;
}

.editing-row td:nth-child(10) .table-input {
  min-width: 340px;
  text-align: left;
}

.editing-row td:nth-child(11) .table-input {
  min-width: 170px;
  text-align: left;
}

.row-actions {
  min-width: 120px;
}

.document-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 118px;
  white-space: nowrap;
}

.document-upload-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 9px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.document-upload-button:hover {
  background: #f3fbf5;
  border-color: #9fd8b4;
}

.document-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.excel-file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid #1f8f49;
  border-radius: 6px;
  background: #eefaf1;
  padding: 0 7px;
  color: #106b35;
}

.excel-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 20px;
  border-radius: 4px;
  background: #1aa34a;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.excel-file-button:hover {
  background: #dcf5e3;
  border-color: #137a3c;
}

.row-actions button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.row-actions button + button {
  margin-left: 6px;
}

td.address {
  min-width: 360px;
  max-width: 440px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
}

.address-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 340px;
}

.address-text {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address-check-line {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.address-check-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #d7e3dc;
  font-size: 10px;
  font-weight: 950;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.address-check-badge:hover {
  filter: brightness(.96);
  text-decoration: none;
}

.address-valid {
  background: #e8f7ee;
  border-color: #9cd9b2;
  color: #0c672c;
}

.address-warning {
  background: #fff5d6;
  border-color: #efca68;
  color: #7b5700;
}

.address-invalid,
.address-error {
  background: #fff0f0;
  border-color: #ffadad;
  color: #c51f1a;
}

.address-unchecked {
  background: #f1f5f3;
  border-color: #d8e2dc;
  color: #53645b;
}

.email-tax-cell {
  display: grid;
  gap: 4px;
  min-width: 150px;
  max-width: 220px;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.email-tax-cell small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.email-tax-edit {
  display: grid;
  gap: 6px;
  min-width: 170px;
}

.email-tax-edit .table-input {
  min-width: 170px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  color: #17231d;
}

.status-registered { color: #17231d; background: #eef2f4; border: 1px solid #d6dee2; }
.status-received { color: #17231d; background: #fff4cb; border: 1px solid #f3d46b; }
.status-shipping { color: #17231d; background: #e8f1ff; border: 1px solid #b8d3ff; }
.status-customs { color: #17231d; background: #e8f1ff; border: 1px solid #b8d3ff; }
.status-attention { color: #c51f1a; background: #fff0f0; border: 1px solid #ffb7b7; }
.status-done { color: #17231d; background: #e7f8ee; border: 1px solid #bce8cc; }

.tracking-pill {
  display: inline-flex;
  max-width: 170px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

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

.form-grid .wide { grid-column: 1 / -1; }

.submit-email-tax-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(340px, .9fr);
  gap: 18px;
}

.upload-panel-stack {
  display: grid;
  gap: 18px;
  align-content: start;
}

.client-list-panel {
  display: grid;
  gap: 14px;
}

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

.client-list-head h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.client-list-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.client-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.client-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
}

.client-table th,
.client-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  border-right: 0;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.client-table th {
  color: var(--muted);
  background: #f6faf7;
  font-size: 12px;
  font-weight: 950;
}

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

.client-table tbody tr:not(.client-detail-row):hover td,
.client-table tbody tr.is-open td {
  background: #f8fcf9;
}

.client-code-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid #bddbc8;
  border-radius: 999px;
  color: var(--green-800);
  background: #eefaf2;
  font-weight: 950;
}

.client-primary strong {
  display: block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}

.client-status.active {
  color: #136b35;
  background: #e7f8ee;
  border-color: #bce8cc;
}

.client-status.inactive {
  color: #68727a;
  background: #f2f4f5;
  border-color: #d6dee2;
}

.client-row-actions button {
  min-width: 64px;
  padding: 9px 12px;
}

.muted-cell {
  color: var(--muted);
}

.client-detail-row td {
  padding: 0 14px 14px;
  background: #f8fcf9;
  white-space: normal;
}

.client-detail-row:hover td {
  background: #f8fcf9;
}

.client-detail-form {
  margin: 0;
  padding: 16px;
  border: 1px solid #cfe3d7;
  border-radius: 10px;
  background: #fff;
}

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

.client-detail-head strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.client-detail-head span {
  color: var(--muted);
  font-weight: 900;
}

.client-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.client-detail-grid .wide {
  grid-column: 1 / -1;
}

.client-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.client-detail-actions button {
  min-width: 132px;
}

.client-detail-form textarea {
  min-height: 74px;
}

.measure-card {
  max-width: 1120px;
  margin: 34px auto;
  border: 1px solid #a9e8bd;
  background: var(--green-100);
}

.measure-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.measure-grid-v2 {
  grid-template-columns: minmax(260px, 2fr) 160px repeat(4, minmax(120px, 1fr));
}

.measure-scan-field {
  grid-column: 1 / -2;
}

.measure-lookup {
  grid-column: -2 / -1;
  min-height: 46px;
}

.measure-carrier {
  grid-column: 1 / span 2;
}

.measure-charge {
  grid-column: span 1;
}

.measure-save {
  grid-column: span 1;
  min-height: 46px;
}

.measure-formula {
  grid-column: span 2;
  align-self: center;
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px dashed #9fd9b2;
  border-radius: 10px;
  background: rgba(255, 255, 255, .72);
  color: #176737;
  font-weight: 900;
  white-space: nowrap;
}

.measure-info {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #ccebd5;
  border-radius: 10px;
  background: #fff;
  color: #2d3a33;
}

.rate-result {
  margin-top: 12px;
  padding: 14px;
  border-radius: 10px;
  background: var(--green-100);
  font-weight: 900;
}

.rate-panel {
  max-width: 1180px;
  margin: 0 auto;
}

.rate-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.rate-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rate-tabs button {
  min-width: 150px;
  min-height: 40px;
  color: var(--green-800);
  background: #eaf7ef;
  border: 1px solid #c8e8d4;
  box-shadow: none;
  transition: background .15s ease, color .15s ease, min-width .15s ease, transform .15s ease, box-shadow .15s ease;
}

.rate-tabs button:hover {
  color: var(--green-900);
  background: #dff4e7;
}

.rate-tabs button.active {
  min-width: 176px;
  min-height: 48px;
  color: #fff;
  background: var(--green-800);
  border-color: var(--green-800);
  box-shadow: 0 10px 18px rgba(18, 55, 34, .16);
  transform: translateY(-2px);
}

.rate-tabs button.active:hover {
  color: #fff;
  background: var(--green-700);
}

.rate-client-select {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.rate-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.rate-table-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.rate-table-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rate-discount-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #9fd8b4;
  border-radius: 999px;
  color: var(--green-800);
  background: #effbf3;
  font-size: 13px;
  font-weight: 950;
}

.rate-table-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.rate-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.rate-matrix {
  min-width: 900px;
  width: max-content;
}

.rate-matrix th,
.rate-matrix td {
  min-width: 104px;
  text-align: center;
  white-space: nowrap;
}

.rate-matrix th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 82px;
  background: #eefaf2;
}

.rate-matrix thead th {
  vertical-align: middle;
}

.rate-matrix small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

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

.tracking-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(20, 32, 24, .54);
}

.tracking-modal {
  width: min(1120px, 94vw);
  max-height: 90vh;
  overflow: auto;
  border-radius: 18px;
  background: #fff;
  padding: 26px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .24);
}

.tracking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tracking-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 950;
}

.tracking-head button {
  min-width: 118px;
}

.tracking-summary {
  display: grid;
  grid-template-columns: 1.15fr .95fr .9fr 1.7fr;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tracking-summary > div {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 78px;
  padding: 14px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.tracking-summary > div:last-child { border-right: 0; }

.tracking-summary small {
  color: #b91c1c;
  font-size: 13px;
  font-weight: 950;
}

.tracking-summary b {
  color: var(--text);
  font-weight: 950;
  line-height: 1.35;
}

.gift-route {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  margin: 18px 0;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfffc;
}

.gift-step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: #56645c;
  font-size: 13px;
  font-weight: 900;
}

.gift-step::before {
  content: "";
  position: absolute;
  top: 15px;
  left: -50%;
  width: 100%;
  height: 4px;
  background: #dff4e7;
  z-index: 0;
}

.gift-step:first-child::before { display: none; }
.gift-step.done::before { background: #4ade80; }
.gift-step.done { color: var(--green-800); }

.gift-box {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border: 2px solid #d6eadf;
  border-radius: 50%;
  background: #fff;
}

.gift-step.done .gift-box { border-color: #16a34a; }

.gift-box::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 10px;
  width: 14px;
  height: 12px;
  border-radius: 3px;
  background: #ff5a5f;
  box-shadow: inset 6px 0 0 #fff, inset 0 5px 0 #fff;
}

.gift-box::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 6px;
  width: 10px;
  height: 6px;
  border: 2px solid #ff5a5f;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.tracking-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 22px;
}

.tracking-body h3 {
  margin: 0 0 14px;
  color: var(--green-800);
  font-size: 22px;
}

.track-timeline {
  display: grid;
}

.track-event {
  display: grid;
  grid-template-columns: 110px 28px minmax(0, 1fr);
  gap: 14px;
  min-height: 82px;
}

.track-date {
  color: #425148;
  font-size: 13px;
  line-height: 1.45;
}

.track-dot {
  position: relative;
}

.track-dot::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 20px;
  bottom: -62px;
  border-left: 1px dashed #13aa7a;
}

.track-event:last-child .track-dot::before { display: none; }

.track-dot::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 12px;
  width: 11px;
  height: 11px;
  border: 2px solid #00a884;
  border-radius: 50%;
  background: #fff;
}

.track-text {
  display: grid;
  align-content: start;
  gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.track-text b {
  font-size: 15px;
  line-height: 1.4;
}

.track-text span,
.track-text em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.track-side {
  display: grid;
  align-content: start;
  gap: 16px;
}

.track-side section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.track-side h3 {
  margin: 0;
  padding: 14px 16px;
  color: #b91c1c;
  background: #fff5f2;
  font-size: 17px;
}

.track-side dl {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px;
}

.track-side dt {
  font-weight: 950;
}

.track-side dd {
  margin: -6px 0 4px;
  line-height: 1.45;
  word-break: break-word;
}

.track-open {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-radius: 8px;
  color: #fff;
  background: var(--green-700);
  font-weight: 900;
  text-decoration: none;
}

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .label-sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 8mm;
  }
  .print-label {
    width: 97mm;
    height: 138mm;
    page-break-inside: avoid;
    border: 1px solid #111;
  }
}

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 18px; }
  .dashboard-grid, .two-col { grid-template-columns: 1fr; }
  .rate-controls, .rate-table-head { align-items: stretch; flex-direction: column; }
  .rate-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .rate-tabs button { min-width: 0; }
  .measure-grid, .measure-grid-v2, .filters, .form-grid, .client-detail-grid, .submit-email-tax-grid, .settlement-summary, .settlement-filters { grid-template-columns: 1fr; }
  .client-list-head, .client-detail-head { align-items: flex-start; flex-direction: column; }
  .client-detail-actions { display: grid; grid-template-columns: 1fr; }
  .client-detail-actions button { width: 100%; }
  .bulk-edit-grid,
  .bulk-edit-actions,
  .bulk-edit-row-2,
  .bulk-edit-row-3,
  .bulk-edit-row-4 { grid-template-columns: 1fr; }
  .measure-scan-field,
  .measure-lookup,
  .measure-carrier,
  .measure-charge,
  .measure-formula,
  .measure-save { grid-column: auto; }
}
.rate-admin-shell {
  display: grid;
  gap: 18px;
}

.rate-admin-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

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

.rate-admin-head h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.rate-admin-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.rate-admin-filters {
  display: grid;
  grid-template-columns: 160px 160px minmax(160px, 1fr) minmax(200px, 1.4fr) 110px;
  gap: 10px;
  margin-bottom: 14px;
}

.rate-admin-toolbar {
  display: grid;
  grid-template-columns: 220px 210px minmax(260px, 1fr) 110px;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.rate-admin-toolbar label,
.rate-admin-subfilter label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  font-size: 12px;
  font-weight: 900;
}

.rate-admin-toolbar label span,
.rate-admin-subfilter label span {
  color: #14251c;
}

.rate-admin-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.rate-admin-tabs button {
  min-height: 38px;
  color: var(--green-800);
  background: #fff;
  border: 1px solid #bdeacb;
}

.rate-admin-tabs button.active {
  color: #fff;
  background: var(--green-800);
  border-color: var(--green-800);
}

.rate-admin-subfilter {
  max-width: 260px;
  margin-bottom: 12px;
}

.rate-matrix-tools {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 110px 130px 130px 110px;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid #d9efe1;
  background: #f7fdf9;
  border-radius: 12px;
  margin-bottom: 12px;
}

.rate-matrix-tools label,
.rate-matrix-commandbar label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  font-size: 12px;
  font-weight: 900;
}

.rate-matrix-commandbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.rate-matrix-commandbar label {
  width: 170px;
}

.rate-matrix-status {
  color: var(--green-800);
  font-size: 12px;
  font-weight: 900;
}

.rate-matrix-wrap {
  overflow: auto;
  max-height: 68vh;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.rate-matrix-admin {
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.rate-matrix-admin th,
.rate-matrix-admin td {
  min-width: 108px;
  padding: 7px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: center;
}

.rate-matrix-admin thead th {
  position: sticky;
  z-index: 3;
  background: #eaf7ef;
  color: #10251a;
  font-weight: 950;
}

.rate-matrix-admin thead tr:first-child th {
  top: 0;
}

.rate-matrix-admin thead tr:nth-child(2) th {
  top: 42px;
  z-index: 4;
  background: #f6fcf8;
}

.rate-matrix-admin tbody th,
.rate-matrix-corner {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 96px;
  background: #f3fbf6;
  color: #123722;
  font-weight: 950;
}

.rate-matrix-corner {
  z-index: 4;
}

.rate-matrix-admin thead tr:nth-child(2) .rate-matrix-corner {
  z-index: 5;
}

.rate-matrix-admin input {
  width: 92px;
  min-height: 34px;
  padding: 6px 8px;
  text-align: right;
}

.rate-matrix-extra-row input {
  width: 86px;
}

.rate-matrix-admin small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.rate-matrix-empty {
  margin-top: 10px;
}

.rate-admin-create {
  display: grid;
  grid-template-columns: 80px 150px 130px 120px 150px 100px 120px 120px 100px 140px 140px minmax(160px, 1fr) 110px;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid #d9efe1;
  background: #f7fdf9;
  border-radius: 12px;
  margin-bottom: 14px;
}

.rate-admin-create.compact {
  grid-template-columns: 80px 130px 130px 90px 120px 100px 90px 130px 130px minmax(160px, 1fr) 110px;
}

.rate-admin-create.compact:has([data-new-rate="carrier"]) {
  grid-template-columns: 130px 80px 130px 130px 90px 120px 100px 90px 130px 130px minmax(160px, 1fr) 110px;
}

.rate-admin-create.rule {
  grid-template-columns: 80px 150px 150px 140px 110px 120px 140px 140px minmax(160px, 1fr) 120px;
}

.rate-admin-create label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 800;
  font-size: 12px;
}

.rate-admin-create label span {
  color: #14251c;
}

.rate-admin-create input,
.rate-admin-create select,
.rate-admin-toolbar input,
.rate-admin-toolbar select,
.rate-admin-subfilter select,
.rate-admin-filters input,
.rate-admin-filters select,
.rate-admin-table input,
.rate-admin-table select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  font: inherit;
  box-sizing: border-box;
}

.rate-admin-create input[type="checkbox"],
.rate-admin-table input[type="checkbox"] {
  width: auto;
  min-height: auto;
  align-self: flex-start;
}

.rate-admin-count {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0 0 10px;
  padding: 7px 12px;
  border: 1px solid #b8e6c8;
  border-radius: 999px;
  background: #f2fbf5;
  color: #0f6b35;
  font-weight: 900;
}

.rate-admin-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.rate-admin-table {
  min-width: 1080px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.rate-admin-table th {
  background: #eefaf2;
  color: #10251a;
  font-weight: 900;
  white-space: nowrap;
}

.rate-admin-table th,
.rate-admin-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px;
  text-align: center;
}

.rate-admin-table td input,
.rate-admin-table td select {
  min-width: 90px;
}

.rate-admin-context {
  min-width: 96px;
  text-align: left;
}

.rate-admin-context strong,
.rate-admin-context small {
  display: block;
}

.rate-admin-context small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.rate-admin-pair,
.rate-admin-period {
  display: grid;
  gap: 6px;
  min-width: 130px;
}

.rate-admin-pair input:first-child {
  font-weight: 900;
}

.rate-admin-table tr:hover td {
  background: #f8fcfa;
}

.rate-admin-note {
  margin: 12px 0 14px;
  padding: 12px 14px;
  border: 1px solid #bdeacb;
  background: #f3fbf6;
  border-radius: 10px;
  color: #14552e;
  font-weight: 800;
  line-height: 1.5;
}

.rate-admin-shared-base td {
  background: #fbfdfb;
}

.rate-admin-shared-base:hover td {
  background: #f3fbf6;
}

.rate-admin-shared-base input:disabled {
  background: #f7faf8;
  color: #34423a;
  border-color: #dbe7df;
  opacity: 1;
  cursor: default;
}

.rate-admin-managed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid #bdeacb;
  background: #eefaf2;
  color: #14552e;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.rate-admin-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  white-space: nowrap;
}

.rate-admin-actions .tiny {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.rate-admin-actions .danger {
  background: #e22d2d;
}

@media (max-width: 1200px) {
  .rate-admin-toolbar,
  .rate-matrix-tools,
  .rate-admin-filters,
  .rate-admin-create,
  .rate-admin-create.compact,
  .rate-admin-create.rule {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rate-admin-tabs {
    display: grid;
    grid-template-columns: 1fr;
  }
}
