/* ============ Reset & base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: #2c3e50;
  background: #f5f7f9;
  line-height: 1.5;
  font-size: 14px;
}
button { font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  background: #fff;
  color: #2c3e50;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #1abc9c;
  box-shadow: 0 0 0 3px rgba(26, 188, 156, 0.15);
}
input[type="checkbox"] { width: auto; }

/* ============ Login ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1abc9c 0%, #2c3e50 100%);
}
.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-size: 24px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.login-card .muted {
  color: #7f8c8d;
  margin-bottom: 24px;
  font-size: 13px;
}
.login-card label {
  display: block;
  font-size: 12px;
  color: #7f8c8d;
  margin-bottom: 6px;
  font-weight: 500;
}
.login-card input {
  margin-bottom: 16px;
}
.login-card .btn {
  width: 100%;
}
.login-card .error {
  background: #fee;
  color: #c0392b;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  border-left: 3px solid #c0392b;
}

/* ============ Layout ============ */
.topbar {
  background: #fff;
  border-bottom: 1px solid #ecf0f1;
  padding: 14px 0;
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .actions {
  display: flex;
  gap: 8px;
}
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
}

.badge {
  background: #1abc9c;
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ============ Cards ============ */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid #ecf0f1;
}
.card h2 {
  font-size: 13px;
  font-weight: 700;
  color: #1abc9c;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header h2 { margin-bottom: 0; }
.card-header .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============ Form ============ */
.row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.field {
  flex: 1;
}
.field.flex-2 { flex: 2; }
.field.flex-half { flex: 0.5; }
.field label {
  display: block;
  font-size: 11px;
  color: #7f8c8d;
  margin-bottom: 4px;
  font-weight: 500;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 8px;
}
.select-saved {
  width: auto;
  min-width: 220px;
  padding: 6px 10px;
  font-size: 12px;
}

.info-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f0faf7;
  border-radius: 8px;
  font-size: 12px;
  color: #555;
  line-height: 1.7;
  border-left: 3px solid #1abc9c;
}

/* ============ Lines ============ */
.line-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: flex-end;
}
.line-row .desc { flex: 3; }
.line-row .qty { flex: 0.5; }
.line-row .price { flex: 1; }
.line-row .total { flex: 1; }
.line-row .total-value {
  padding: 9px 11px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  border: 1px solid #eef0f2;
  color: #2c3e50;
}
.line-row .remove-btn {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 22px;
  padding: 0 6px;
  line-height: 1;
  align-self: flex-end;
  margin-bottom: 4px;
  transition: opacity 0.15s;
}
.line-row .remove-btn:disabled { opacity: 0.25; cursor: not-allowed; }

.total-display {
  text-align: right;
  font-size: 22px;
  font-weight: 700;
  color: #2c3e50;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid #ecf0f1;
}

/* ============ Buttons ============ */
.btn {
  padding: 10px 20px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #dfe6e9;
  background: #fff;
  color: #2c3e50;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover:not(:disabled) { background: #f8f9fa; transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.small { padding: 6px 14px; font-size: 12px; }
.btn.big {
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 700;
  width: 100%;
}
.btn.primary {
  background: #1abc9c;
  color: #fff;
  border-color: #1abc9c;
}
.btn.primary:hover:not(:disabled) {
  background: #16a085;
  border-color: #16a085;
  box-shadow: 0 4px 12px rgba(26, 188, 156, 0.3);
}
.btn.ghost {
  background: transparent;
  border-color: #dfe6e9;
  color: #7f8c8d;
}
.btn.dashed {
  background: #fff;
  border: 1px dashed #bdc3c7;
  color: #7f8c8d;
  width: 100%;
  padding: 10px;
  margin-top: 4px;
}
.btn.dashed:hover:not(:disabled) {
  border-color: #1abc9c;
  color: #1abc9c;
}

.actions-bar {
  margin: 24px 0 40px;
}

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 90%;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
}
.history-item {
  padding: 12px 14px;
  border-bottom: 1px solid #ecf0f1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.history-item .meta {
  color: #7f8c8d;
  font-size: 11px;
  margin-top: 2px;
}
.history-item .amount {
  font-weight: 700;
  color: #1abc9c;
}
.history-empty {
  text-align: center;
  color: #7f8c8d;
  padding: 40px 20px;
  font-size: 13px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c3e50;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 200;
  animation: slideUp 0.2s ease-out;
}
.toast[hidden] { display: none; }
.toast.success { background: #1abc9c; }
.toast.error { background: #e74c3c; }
@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .row { flex-direction: column; gap: 8px; }
  .line-row { flex-wrap: wrap; }
  .line-row .desc { flex: 1 1 100%; }
  .topbar h1 { font-size: 15px; }
  .card { padding: 16px; }
}
