* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f6fa;
  color: #2c3e50;
  padding: 20px;
  line-height: 1.5;
}
.container { max-width: 1400px; margin: 0 auto; }
h1 { color: #2c3e50; margin-bottom: 8px; font-size: 28px; }
.subtitle { color: #7f8c8d; margin-bottom: 24px; font-size: 14px; }

.header-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 8px;
}
.user-info {
  display: flex; align-items: center; gap: 8px;
  background: white; padding: 8px 14px;
  border: 1px solid #e0e0e0; border-radius: 20px;
  font-size: 13px; color: #2c3e50; min-height: 36px;
}
.user-info .user-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: #3498db; color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
}
.user-info .user-email { font-weight: 600; }
.user-info .user-status {
  color: #95a5a6; font-size: 11px;
}
.user-info.api-down { background: #fef5e7; border-color: #f39c12; color: #d68910; }
.user-info .btn-logout {
  background: transparent; color: #95a5a6;
  border: 1px solid #dcdfe6; border-radius: 14px;
  padding: 4px 12px; font-size: 11px; cursor: pointer;
  margin-left: 6px;
}
.user-info .btn-logout:hover { color: #c0392b; border-color: #c0392b; }

/* Login gate overlay */
.login-gate {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #ecf5fc 0%, #f5f6fa 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: white; border-radius: 12px;
  padding: 40px 48px; text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  max-width: 420px; width: calc(100% - 32px);
}
.login-card h1 { margin-bottom: 10px; }
.login-card .muted { margin-bottom: 28px; }
.login-status {
  font-size: 13px; color: #7f8c8d; margin: 16px 0 12px;
}
#g_id_button { display: flex; justify-content: center; margin: 8px 0; }
.login-domain-hint {
  font-size: 11px; color: #95a5a6;
  margin-top: 16px;
}

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid #e0e0e0; flex-wrap: wrap; }
.tab {
  padding: 12px 20px; cursor: pointer; background: none; border: none;
  font-size: 14px; font-weight: 500; color: #7f8c8d;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.2s;
}
.tab.active { color: #3498db; border-bottom-color: #3498db; }
.tab:hover { color: #2c3e50; }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: white; border-radius: 8px; padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 20px;
}
.card h2 { font-size: 18px; margin-bottom: 16px; color: #2c3e50; }
.card h3 { font-size: 15px; margin: 16px 0 8px; color: #34495e; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.form-group { flex: 1; min-width: 200px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: #7f8c8d; margin-bottom: 6px; text-transform: uppercase;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #dcdfe6;
  border-radius: 6px; font-size: 14px; background: white;
  font-family: inherit;
}
.form-group textarea { min-height: 70px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: #3498db;
}

.upload-zone {
  border: 2px dashed #bdc3c7; border-radius: 8px; padding: 40px;
  text-align: center; cursor: pointer; transition: all 0.2s;
  background: #fafbfc;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #3498db; background: #ecf5fc;
}
.upload-zone p { color: #7f8c8d; margin: 8px 0; }
.upload-zone .icon { font-size: 36px; margin-bottom: 8px; }

button {
  padding: 10px 20px; border: none; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: #3498db; color: white; }
.btn-primary:hover { background: #2980b9; }
.btn-primary:disabled { background: #bdc3c7; cursor: not-allowed; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-success { background: #27ae60; color: white; }
.btn-success:hover { background: #229954; }
.btn-danger { background: #e74c3c; color: white; padding: 6px 12px; font-size: 12px; }
.btn-danger:hover { background: #c0392b; }
.btn-small { padding: 6px 12px; font-size: 12px; }

.button-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.status {
  padding: 12px 16px; border-radius: 6px; margin: 12px 0;
  font-size: 14px;
}
.status.info { background: #ecf5fc; color: #2980b9; border-left: 3px solid #3498db; }
.status.success { background: #e8f8f0; color: #229954; border-left: 3px solid #27ae60; }
.status.warning { background: #fef5e7; color: #d68910; border-left: 3px solid #f39c12; }
.status.error { background: #fce4e0; color: #c0392b; border-left: 3px solid #e74c3c; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
th { background: #34495e; color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
td { padding: 8px; border-bottom: 1px solid #ecf0f1; }
tr:hover td { background: #f8f9fa; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.badge-bundle { background: #fff3cd; color: #856404; }
.badge-individual { background: #d4edda; color: #155724; }
.badge-unknown { background: #f8d7da; color: #721c24; }
.badge-instant { background: #fce4e0; color: #c0392b; }
.badge-sameday { background: #fef5e7; color: #d68910; }
.badge-reguler { background: #ecf5fc; color: #2980b9; }

.kitab-output {
  background: white; padding: 24px; border-radius: 8px;
  border: 1px solid #e0e0e0; margin-top: 20px;
}
.kitab-header {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px; padding-bottom: 16px; border-bottom: 2px solid #2c3e50;
  margin-bottom: 16px;
}
.kitab-header div { font-size: 13px; }
.kitab-header strong { display: block; font-size: 11px; color: #7f8c8d; text-transform: uppercase; margin-bottom: 2px; }

.summary-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 20px;
}
.stat-box {
  background: #f8f9fa; padding: 12px; border-radius: 6px;
  border-left: 3px solid #3498db;
}
.stat-box .label { font-size: 11px; color: #7f8c8d; text-transform: uppercase; }
.stat-box .value { font-size: 22px; font-weight: 700; color: #2c3e50; margin-top: 2px; }

.composition-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 6px;
  padding: 6px; background: #f8f9fa; border-radius: 4px;
}
.composition-row select { flex: 1; padding: 6px; font-size: 13px; }
.composition-row input { width: 60px; padding: 6px; font-size: 13px; }

.search-box {
  width: 100%; padding: 10px 12px; border: 1px solid #dcdfe6;
  border-radius: 6px; font-size: 14px; margin-bottom: 12px;
}

.muted { color: #95a5a6; font-size: 12px; }

/* Performance charts */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.chart-bar { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.chart-label { width: 140px; font-size: 12px; }
.chart-track { flex: 1; height: 24px; background: #ecf0f1; border-radius: 4px; overflow: hidden; position: relative; }
.chart-fill { height: 100%; transition: width 0.4s; display: flex; align-items: center; padding-left: 8px; color: white; font-size: 11px; font-weight: 600; }

/* Master Shipment sections (chips + add inputs) */
.ms-section {
  padding: 14px 0;
  border-bottom: 1px solid #ecf0f1;
}
.ms-section:last-of-type { border-bottom: none; }
.ms-section h3 {
  font-size: 14px; color: #2c3e50; margin: 0 0 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.ms-chip-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 8px 0 10px;
  min-height: 28px;
}
.ms-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #ecf5fc; color: #2980b9;
  border: 1px solid #cfe5f5;
  border-radius: 16px;
  padding: 4px 4px 4px 12px;
  font-size: 13px; font-weight: 500;
}
.ms-chip-label { padding-right: 2px; }
.ms-chip-edit, .ms-chip-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: none; background: transparent;
  border-radius: 50%; cursor: pointer;
  font-size: 12px; padding: 0; color: #2980b9;
}
.ms-chip-edit:hover { background: rgba(41,128,185,0.15); }
.ms-chip-del { color: #e74c3c; font-size: 16px; line-height: 1; }
.ms-chip-del:hover { background: rgba(231,76,60,0.15); }
.ms-add {
  display: flex; gap: 8px; align-items: center;
  margin-top: 4px;
}
.ms-add input {
  flex: 1; padding: 8px 12px;
  border: 1px solid #dcdfe6; border-radius: 6px;
  font-size: 13px;
}
.ms-add input:focus { outline: none; border-color: #3498db; }

/* Resi Card (form per resi in Create Resi tab) */
.resi-card {
  background: #f8f9fa;
  border: 1px solid #dcdfe6;
  border-left: 4px solid #3498db;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}
.resi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e0e0e0;
}
.resi-card-header strong { color: #2c3e50; font-size: 15px; }
.resi-cargo-block {
  background: #fef5e7;
  padding: 10px;
  border-radius: 6px;
  border-left: 3px solid #f39c12;
  margin-bottom: 12px;
}
.copy-products-row {
  display: flex; align-items: center; gap: 8px;
  background: #ecf5fc; padding: 8px 10px;
  border-radius: 6px; margin-bottom: 8px;
  font-size: 13px;
}
.copy-products-row label {
  margin: 0; text-transform: none; font-size: 13px;
  color: #2c3e50; font-weight: 500; cursor: pointer;
}
.copy-products-row select {
  flex: 0 1 auto; padding: 4px 8px; font-size: 13px;
  border: 1px solid #dcdfe6; border-radius: 4px;
}

/* Searchable SKU Picker — custom dropdown replacing native datalist */
.sku-picker {
  position: relative;
  flex: 2;
  min-width: 0;
}
.sku-picker-input {
  width: 100%;
  padding: 8px 28px 8px 10px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 13px;
  background: white;
}
.sku-picker-input:focus {
  outline: none;
  border-color: #3498db;
}
.sku-picker.disabled .sku-picker-input { background: #f5f6fa; cursor: not-allowed; }
.sku-picker-caret {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #95a5a6;
  font-size: 10px;
}
.sku-picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 100;
  background: white;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  max-height: 280px;
  overflow-y: auto;
}
.sku-picker.open .sku-picker-dropdown { display: block; }
.sku-option {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f5f6fa;
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.sku-option:hover, .sku-option.hover { background: #ecf5fc; }
.sku-option:last-child { border-bottom: none; }
.sku-option-code {
  font-weight: 700;
  color: #2c3e50;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.sku-option-name {
  color: #34495e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sku-option-meta {
  color: #95a5a6;
  font-size: 11px;
}
.sku-option-empty {
  padding: 10px 12px;
  color: #95a5a6;
  font-size: 12px;
  text-align: center;
  font-style: italic;
}

/* Manual Kitab — order card with SS thumbnail side-by-side with form */
.mk-order-card .mk-order-body {
  display: flex; gap: 16px; align-items: flex-start;
}
.mk-ss-thumb {
  flex: 0 0 180px;
  display: block;
  border: 1px solid #dcdfe6; border-radius: 6px;
  overflow: hidden; background: #f8f9fa;
  text-decoration: none;
}
.mk-ss-thumb img { width: 100%; height: auto; display: block; }
.mk-ss-empty {
  display: flex; align-items: center; justify-content: center;
  height: 180px; color: #95a5a6; font-size: 12px;
}
.mk-order-fields { flex: 1; min-width: 0; }
@media (max-width: 768px) {
  .mk-order-card .mk-order-body { flex-direction: column; }
  .mk-ss-thumb { flex: none; width: 100%; max-width: 280px; }
}

/* Resi Label Preview - 10x15 cm portrait = ~378 x 567 px at 96dpi */
.resi-preview-container {
  display: flex; justify-content: center; padding: 16px; background: #ecf0f1; border-radius: 8px;
  margin-bottom: 12px;
}
.resi-label {
  width: 378px; height: 567px;
  background: white; padding: 12px;
  border: 2px dashed #95a5a6;
  font-family: Arial, sans-serif;
  font-size: 10px;
  position: relative;
  display: flex; flex-direction: column;
}
.resi-brand-bar { background: #2c3e50; color: white; padding: 6px 8px; font-weight: 700; font-size: 14px; text-align: center; letter-spacing: 1px; }
.resi-logo-section { text-align: center; padding: 8px 4px 4px; }
.resi-logo-img { height: 42px; max-width: 80%; object-fit: contain; }
.resi-orderno { font-size: 11px; font-weight: 700; letter-spacing: 1px; margin-top: 4px; color: #2c3e50; }
.resi-section { padding: 6px 8px; border-bottom: 1px solid #2c3e50; }
.resi-section-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #2c3e50; }
.resi-label-text { font-size: 9px; color: #555; text-transform: uppercase; font-weight: 600; }
.resi-value { font-size: 11px; font-weight: 600; margin-top: 1px; line-height: 1.3; }
.resi-address { font-size: 10px; line-height: 1.35; margin-top: 2px; }
.resi-products { flex: 1; padding: 6px 8px; border-bottom: 1px solid #2c3e50; overflow: hidden; }
.resi-products table { font-size: 9px; margin: 0; }
.resi-products th { background: #34495e; padding: 3px 4px; font-size: 9px; }
.resi-products td { padding: 3px 4px; font-size: 9px; }
.resi-footer { padding: 6px 8px; display: flex; justify-content: space-between; align-items: center; }

@media print {
  body { background: white; padding: 0; }
  .no-print { display: none !important; }
  .card { box-shadow: none; padding: 0; }
  .kitab-output { border: none; padding: 0; }
}

@media print {
  @page resi { size: 100mm 150mm; margin: 0; }
}
