/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.1), 0 8px 32px rgba(0,0,0,.06);
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.header-title .logo {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.header-nav button {
  background: none;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}

.header-nav button:hover {
  background: var(--bg);
  color: var(--text);
}

.header-nav button.active {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 600;
}

.header-nav .header-logout {
  margin-left: 8px;
  color: #ef4444;
  border-left: 1px solid var(--border, #e5e7eb);
  border-radius: 0;
  padding-left: 16px;
}

.header-nav .header-logout:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* ===== Main Layout ===== */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ===== Home Page ===== */
.home-welcome {
  margin-bottom: 32px;
}

.home-welcome h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.home-welcome p {
  color: var(--text-secondary);
  font-size: 15px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.menu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.menu-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.menu-card .card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.menu-card .card-icon.product { background: #dbeafe; color: #2563eb; }
.menu-card .card-icon.client  { background: #dcfce7; color: #16a34a; }
.menu-card .card-icon.company { background: #fef3c7; color: #d97706; }
.menu-card .card-icon.sales   { background: #ede9fe; color: #7c3aed; }
.menu-card .card-icon.stats   { background: #e0f2fe; color: #0284c7; }

.menu-card .card-body h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.menu-card .card-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.menu-card .card-arrow {
  margin-left: auto;
  align-self: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: transform .2s;
}

.menu-card:hover .card-arrow {
  transform: translateX(4px);
  color: var(--primary);
}

/* ===== Sub Page ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  outline: none;
}

.sort-select:focus {
  border-color: var(--primary);
}

.list-search-input {
  width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.list-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fecaca;
}

.btn-success {
  background: #16a34a;
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ===== Table ===== */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-scroll-container {
  max-height: 75vh;
  overflow-y: auto;
}

.list-scroll-container .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

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

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.product-list-table th,
.product-list-table td,
.client-list-table th,
.client-list-table td {
  padding-top: 10px;
  padding-bottom: 10px;
}

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

.data-table tr:hover td {
  background: #f8fafc;
}

.table-actions {
  display: flex;
  gap: 6px;
}

/* ===== Sales Register: Monthly Accordion ===== */
.sales-accordion-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: hidden;
}

.sales-accordion-group {
  border-bottom: 1px solid var(--border);
}

.sales-accordion-group:last-child {
  border-bottom: none;
}

.sales-accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #f8fafc;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

.sales-accordion-header:hover {
  background: #eef2f7;
}

.sales-accordion-group.is-expanded .sales-accordion-header {
  background: #e0e7ff;
}

.sales-accordion-arrow {
  font-size: 11px;
  color: var(--text-secondary);
}

.sales-accordion-body {
  padding: 12px 16px 16px;
}

.sales-accordion-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sales-accordion-summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sales-accordion-summary-item span {
  font-size: 12px;
  color: var(--text-secondary);
}

.sales-accordion-summary-item strong {
  font-size: 16px;
  color: var(--text);
}

.sales-accordion-date-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.sales-accordion-date-table td {
  padding: 10px 14px;
}

.ip-search-date.is-selected {
  color: #dc2626;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5;
}

.empty-state p {
  font-size: 15px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn .15s;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s;
}

.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* ===== Company Info ===== */
.company-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.company-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.company-form .form-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== Product Image Upload ===== */
.product-img-upload {
  display: flex;
  align-items: center;
  gap: 16px;
}

.product-img-preview {
  width: 100px;
  height: 100px;
  border-radius: 10px;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: #f8fafc;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color .15s;
}

.product-img-preview:hover {
  border-color: var(--primary);
}

.product-img-preview.has-image {
  border-style: solid;
  border-color: var(--border);
}

.product-img-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-img-preview .placeholder-icon {
  font-size: 28px;
  color: #cbd5e1;
  margin-bottom: 2px;
}

.product-img-preview .placeholder-text {
  font-size: 11px;
  color: var(--text-secondary);
}

.product-img-actions {
  display: flex;
  gap: 8px;
}

.product-list-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-list-thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.product-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-list-thumb span {
  font-size: 18px;
}

/* ===== Logo Upload ===== */
.logo-upload-area {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo-preview {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: #f8fafc;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color .15s;
}

.logo-preview:hover {
  border-color: var(--primary);
}

.logo-preview.has-image {
  border-style: solid;
  border-color: var(--border);
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-preview .placeholder-icon {
  font-size: 32px;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.logo-preview .placeholder-text {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.logo-actions p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.logo-actions .logo-btns {
  display: flex;
  gap: 8px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s;
  z-index: 300;
}

/* ===== Ledger ===== */
.text-right { text-align: right; }

.ledger-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.summary-value {
  font-size: 18px;
  font-weight: 700;
}

/* Receivable Bar */
.receivable-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: center;
}

.receivable-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.receivable-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.receivable-value {
  font-size: 16px;
  font-weight: 700;
}

.receivable-highlight {
  margin-left: auto;
  padding: 8px 18px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 8px;
}

.ledger-actions-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.ledger-type-btn {
  font-weight: 700;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
}

.ledger-type-btn:hover {
  opacity: .8;
}

.ledger-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ledger-table th,
.ledger-table td {
  font-size: 13px;
  padding: 12px 10px;
}

.ledger-table th.text-right,
.ledger-table td.text-right {
  text-align: right;
  min-width: 80px;
  white-space: nowrap;
}

.group-date,
.group-type {
  vertical-align: middle;
  border-bottom: 2px solid var(--border);
}

.group-subtotal td {
  background: #f1f5f9;
  border-bottom: 2px solid var(--border);
}

.group-date-cell {
  vertical-align: middle;
  text-align: center;
  border-bottom: 2px solid var(--border);
  min-width: 100px;
}

.group-date-text {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.group-actions-icons {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all .15s;
}

.icon-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
}

.icon-btn-danger:hover {
  background: #fee2e2;
  border-color: #dc2626;
}

.icon-btn-print:hover {
  background: #dbeafe;
  border-color: #2563eb;
}

/* Group Edit Modal */
.group-edit-entries {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 55vh;
  overflow-y: auto;
}

.group-edit-row {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.group-edit-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.group-edit-row .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.group-edit-row .calc-fields {
  margin-top: 8px;
  margin-bottom: 8px;
}

.calc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: -4px;
  margin-bottom: 16px;
}

.calc-fields .form-group {
  margin-bottom: 0;
}

.calc-fields input[readonly] {
  background: #e2e8f0;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 640px) {
  .ledger-summary { grid-template-columns: repeat(2, 1fr); }
  .ledger-actions-bar { flex-wrap: wrap; }
  .calc-fields { grid-template-columns: 1fr; }
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .menu-grid { grid-template-columns: 1fr; }
  .company-form .form-row { grid-template-columns: 1fr; }
  .header { padding: 0 16px; }
  .main-content { padding: 20px 16px; }
}

/* ===== Sales Register ===== */
.sales-register-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.sr-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.sr-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sr-items-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.sr-table {
  table-layout: fixed;
}

.sr-table th,
.sr-table td {
  padding: 10px 8px;
  text-align: center;
  font-size: 13px;
}

.sr-table th:nth-child(1),
.sr-table td:nth-child(1) {
  width: 30%;
}

.sr-table th:nth-child(2),
.sr-table td:nth-child(2),
.sr-table th:nth-child(3),
.sr-table td:nth-child(3),
.sr-table th:nth-child(4),
.sr-table td:nth-child(4),
.sr-table th:nth-child(5),
.sr-table td:nth-child(5),
.sr-table th:nth-child(6),
.sr-table td:nth-child(6) {
  width: 12%;
}

.sr-table th:nth-child(7),
.sr-table td:nth-child(7) {
  width: 10%;
}

.sr-table select,
.sr-table input {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}

.sr-table select {
  text-align: left;
}

.sr-table input[readonly] {
  background: #f1f5f9;
  color: var(--primary);
  font-weight: 700;
}

.sr-summary {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding: 14px 18px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sr-summary-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sr-summary-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.sr-summary-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

.sr-existing {
  margin-bottom: 24px;
}

.sr-existing h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.sr-history-table th,
.sr-history-table td {
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
  text-align: center;
}

.sr-history-table .sr-client-cell {
  text-align: left;
}

.sr-history-table .sr-product-cell {
  text-align: left;
}

.sr-search-buy-price {
  width: 96px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: right;
  font-size: 13px;
}

.sr-new-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.sr-client-cell {
  background: #f8fafc;
  vertical-align: middle;
  font-weight: 600;
}

.sr-day-summary {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.sr-day-summary strong {
  color: var(--primary);
  font-size: 16px;
}

/* ===== Import Products ===== */
.import-products-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

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

.import-mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: all .2s ease;
}

.import-mode-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.import-mode-icon {
  font-size: 28px;
}

.import-mode-card strong {
  font-size: 20px;
  color: var(--text);
}

.import-mode-card span:last-child {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.ip-search-table {
  max-width: 420px;
}

.ip-search-table th,
.ip-search-table td {
  text-align: center;
}

.ip-search-date {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
}

.ip-search-detail {
  margin-top: 24px;
}

.receivable-stat-table tfoot {
  background: #f8fafc;
  color: var(--primary);
}

.receivable-stat-table tfoot td {
  border-top: 2px solid var(--border);
}

.statistics-filter {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.statistics-filter .form-group {
  margin-bottom: 0;
}

.radio-group {
  display: flex;
  gap: 14px;
  padding: 10px 0;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 0;
}

.radio-option input[type="radio"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.tax-attach-bar {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.ip-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ip-items-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.ip-table {
  table-layout: fixed;
}

.ip-table th,
.ip-table td {
  padding: 10px 8px;
  text-align: center;
  font-size: 13px;
}

.ip-table th:nth-child(1),
.ip-table td:nth-child(1) { width: 6%; }

.ip-table th:nth-child(2),
.ip-table td:nth-child(2) { width: 15%; }

.ip-table th:nth-child(3),
.ip-table td:nth-child(3) { width: 21%; }

.ip-table th:nth-child(4),
.ip-table td:nth-child(4) { width: 7%; }

.ip-table th:nth-child(5),
.ip-table td:nth-child(5) { width: 7%; }

.ip-table th:nth-child(6),
.ip-table td:nth-child(6) { width: 8%; }

.ip-table th:nth-child(7),
.ip-table td:nth-child(7) { width: 9%; }

.ip-table th:nth-child(8),
.ip-table td:nth-child(8) { width: 7%; }

.ip-table th:nth-child(9),
.ip-table td:nth-child(9) { width: 8%; }

.ip-table th:nth-child(10),
.ip-table td:nth-child(10) { width: 7%; }

.ip-table th:nth-child(11),
.ip-table td:nth-child(11) { width: 5%; }

.ip-table select,
.ip-table input {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}

.ip-table select {
  text-align: left;
}

.ip-table input[readonly] {
  background: #f1f5f9;
  color: var(--primary);
  font-weight: 700;
}

.ip-saved-section {
  margin-top: 32px;
}

.ip-saved-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.ip-saved-summary {
  display: flex;
  gap: 24px;
  justify-content: flex-end;
  margin-top: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.ip-saved-summary strong {
  color: var(--text);
  margin-right: 4px;
}

.ip-saved-summary span:last-child strong {
  color: var(--primary);
}

.ip-saved-summary span:last-child {
  color: var(--primary);
  font-weight: 700;
}

.ip-saved-table tfoot .ip-saved-total-row {
  background: #f1f5f9;
  font-weight: 700;
}

.ip-saved-table tfoot .ip-saved-total-row td {
  border-top: 2px solid var(--border);
  color: var(--text);
}

.ip-saved-table tfoot .ip-saved-total-row td:nth-child(5),
.ip-saved-table tfoot .ip-saved-total-row td:nth-child(8),
.ip-saved-table tfoot .ip-saved-total-row td:nth-child(9) {
  color: var(--primary);
}

.ip-exchange-rate {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.ip-exchange-rate label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.ip-exchange-rate input {
  width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  text-align: right;
}

.ip-second-page-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.ip-second-page-section {
  margin-top: 28px;
}

.ip-second-page-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.ip-page-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-secondary);
}

.ip-page-date strong,
.ip-page-company {
  color: var(--text);
  font-weight: 700;
}

.ip-doc-number {
  width: 96px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  letter-spacing: 1px;
}

.ip-third-extra-code {
  width: 190px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  letter-spacing: 1px;
}

.ip-origin-note {
  color: var(--text);
  font-weight: 700;
}

.ip-second-page-table td:nth-child(3) {
  min-width: 220px;
  text-align: left;
  white-space: normal;
}

.ip-second-page-table {
  table-layout: fixed;
  min-width: 980px;
}

.ip-second-page-table th,
.ip-second-page-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.ip-second-page-table th:nth-child(1),
.ip-second-page-table td:nth-child(1) { width: 90px; }

.ip-second-page-table th:nth-child(2),
.ip-second-page-table td:nth-child(2) { width: 90px; }

.ip-second-page-table th:nth-child(3),
.ip-second-page-table td:nth-child(3) {
  width: 240px;
  text-align: left;
}

.ip-second-page-table th:nth-child(4),
.ip-second-page-table td:nth-child(4),
.ip-second-page-table th:nth-child(5),
.ip-second-page-table td:nth-child(5),
.ip-second-page-table th:nth-child(6),
.ip-second-page-table td:nth-child(6),
.ip-second-page-table th:nth-child(7),
.ip-second-page-table td:nth-child(7),
.ip-second-page-table th:nth-child(8),
.ip-second-page-table td:nth-child(8),
.ip-second-page-table th:nth-child(9),
.ip-second-page-table td:nth-child(9) {
  width: 95px;
  text-align: center;
}

.ip-second-page-costs {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.ip-second-page-costs .form-group {
  margin-bottom: 0;
}

.ip-third-page-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.ip-third-page-section {
  margin-top: 28px;
}

.ip-third-page-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.ip-third-page-table {
  table-layout: fixed;
  min-width: 980px;
}

.ip-third-page-table th,
.ip-third-page-table td {
  padding: 10px 12px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.ip-third-page-table th:first-child,
.ip-third-page-table td:first-child {
  width: 220px;
  text-align: left;
}

.ip-third-page-table th:nth-child(7),
.ip-third-page-table td:nth-child(7),
.ip-third-page-table th:last-child,
.ip-third-page-table td:last-child {
  color: var(--primary);
  font-weight: 700;
}

.ip-third-page-total-row {
  background: #f1f5f9;
}

.ip-third-page-total-row td {
  border-top: 2px solid var(--border);
}

.ip-reference-amount {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
}

.ip-reference-amount span {
  color: var(--text-secondary);
  font-weight: 700;
}

.ip-reference-amount strong {
  color: var(--primary);
  font-size: 18px;
}

.ip-apply-date {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.ip-apply-date label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.ip-apply-date input {
  width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.ip-complete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.import-pdf-options {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.import-pdf-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.import-pdf-options input {
  width: 18px;
  height: 18px;
}

.ip-saved-table th,
.ip-saved-table td {
  padding: 8px 10px;
  text-align: center;
  font-size: 13px;
  white-space: nowrap;
}

.ip-saved-table th {
  font-weight: 600;
  background: #f8fafc;
}

.card-icon.import { background: #fef3c7; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}

.login-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.login-box h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.login-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-form .form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.login-form .form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.login-error {
  color: #dc2626;
  font-size: 13px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
}

.login-submit {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  margin-top: 4px;
}

/* ===== Sale Price Hint Tooltip ===== */
.price-hint-tooltip {
  position: fixed;
  z-index: 250; /* .modal-overlay(200)보다 위, .toast(300)보다 아래 */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 10px 14px;
  min-width: 220px;
  max-width: 320px;
  font-size: 12px;
}

.price-hint-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

.price-hint-section + .price-hint-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.price-hint-title {
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.price-hint-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

.price-hint-date { color: var(--text-secondary); }
.price-hint-client { color: var(--text-secondary); flex: 1; text-align: left; }
.price-hint-price { font-weight: 700; color: var(--primary); }

.price-hint-empty {
  color: var(--text-secondary);
  padding: 2px 0;
}

/* ===== Searchable Product Combobox ===== */
.product-combobox {
  position: relative;
}

.product-combobox-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  font-family: inherit;
}

.product-combobox-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.product-combobox-list {
  position: fixed;
  z-index: 260; /* .price-hint-tooltip(250)보다 위, .toast(300)보다 아래 */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
}

.product-combobox-item {
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.product-combobox-item:hover,
.product-combobox-item.active {
  background: #eff6ff;
  color: var(--primary);
}

.product-combobox-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-combobox-code {
  color: var(--text-secondary);
  font-size: 12px;
}

.product-combobox-stock {
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}

.product-combobox-empty {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-secondary);
}
