* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #333;
  font-size: 14px;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 8px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.login-title {
  font-size: 20px;
  margin-bottom: 4px;
}

.login-sub {
  color: #888;
  font-size: 13px;
  margin-bottom: 20px;
}

header {
  background: #1a1a2e;
  padding: 12px 24px;
}

nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

main {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
}

h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 18px; margin-bottom: 12px; }

a { color: #4361ee; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  font-weight: 500;
  line-height: 1.4;
}

.btn-primary { background: #4361ee; color: #fff; }
.btn-primary:hover { background: #3a56d4; }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-secondary:hover { background: #d0d0d0; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: #666;
}

.card {
  background: #fff;
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 16px;
}

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

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 13px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-in_progress { background: #cce5ff; color: #004085; }
.badge-completed { background: #d4edda; color: #155724; }
.badge-manual { background: #e2e3e5; color: #383d41; }

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid #ddd;
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}

.tab:hover { color: #333; }
.tab.active { color: #4361ee; border-bottom-color: #4361ee; }

.tab-count {
  display: inline-block;
  background: #e0e0e0;
  color: #555;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
}

.tab.active .tab-count { background: #4361ee; color: #fff; }

.item-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
  margin-bottom: 8px;
}

.item-row .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

.item-row .form-group.narrow {
  flex: 0 0 80px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.upload-section {
  border: 2px dashed #ccc;
  padding: 16px;
  border-radius: 6px;
  text-align: center;
  margin: 12px 0;
}

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

.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

.sr-no {
  background: #4361ee;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  align-self: center;
}

.order-meta {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.order-meta div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-meta .label {
  font-size: 11px;
  text-transform: uppercase;
  color: #999;
  font-weight: 600;
}

.status-select {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}

.material-search {
  position: relative;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 150px;
  overflow-y: auto;
  z-index: 10;
}

.search-dropdown div {
  padding: 8px 10px;
  cursor: pointer;
}

.search-dropdown div:hover {
  background: #eef;
}

.excel-fields {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.excel-fields .form-group {
  flex: 1;
}

.paste-grid-wrap {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
  margin-top: 12px;
  background: #fafbfc;
}

.paste-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 4px;
}

.paste-grid {
  box-shadow: none;
  border: 1px solid #ddd;
}

.paste-grid th {
  font-size: 11px;
  padding: 6px 10px;
}

.paste-grid td {
  padding: 2px 4px;
  border-bottom: 1px solid #eee;
}

.paste-grid td.grid-rownum {
  text-align: center;
  color: #999;
  font-size: 11px;
  width: 40px;
  padding: 6px;
}

.paste-grid input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 13px;
  background: transparent;
}

.paste-grid input:focus {
  border-color: #4361ee;
  background: #fff;
  outline: none;
}

.error-msg {
  background: #f8d7da;
  color: #721c24;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
  display: none;
}

.error-msg.show {
  display: block;
}

/* Homepage */
.home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 16px;
}

.home-card {
  background: #fff;
  border-radius: 8px;
  padding: 32px 24px;
  text-align: center;
  text-decoration: none;
  color: #333;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: box-shadow .15s, transform .15s;
  position: relative;
}

.home-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.home-card h2 { font-size: 17px; margin-bottom: 6px; }
.home-card p { font-size: 13px; color: #666; }

.home-icon {
  font-size: 32px;
  margin-bottom: 12px;
  color: #4361ee;
}

.home-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #4361ee;
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

/* Optimisation visuals */
.stats-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

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

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #999;
  font-weight: 600;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #333;
}

.sheet-visual {
  position: relative;
  background: #f0f0f0;
  border: 2px solid #999;
  margin: 12px 0;
  overflow: hidden;
}

.sheet-piece {
  position: absolute;
  border: 1px solid rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  line-height: 1.3;
  font-weight: 500;
  color: #333;
  z-index: 2;
}

.piece-dim {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.piece-label {
  font-size: 9px;
  opacity: .65;
  white-space: nowrap;
}

.sheet-waste {
  position: absolute;
  background: #e0e0e0;
  border: 1px dashed rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

.sheet-waste span {
  font-size: 9px;
  color: #777;
  font-weight: 500;
  white-space: nowrap;
}

.sheet-stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
}

.sheet-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.15);
}
