@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #0f766e;
  --primary-hover: #0d9488;
  --primary-light: #ccfbf1;
  --primary-dark: #115e59;
  --secondary: #f1f5f9;
  --secondary-text: #334155;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --success: #10b981;
  --success-light: #d1fae5;
  --success-text: #065f46;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-text: #92400e;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-text: #991b1b;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-text: #1e40af;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.5;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
  min-height: 40px;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.28);
}
.btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
}
.btn.secondary {
  background: #f1f5f9;
  color: var(--secondary-text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger {
  background: var(--danger-light);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn.danger:hover { background: #fecaca; }
.btn.success {
  background: var(--success-light);
  color: var(--success-text);
}
.btn.success:hover { background: #a7f3d0; }
.btn.ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn.ghost:hover {
  background: #f1f5f9;
  color: var(--text);
}
.btn.wide { width: 100%; }
.btn.sm {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 32px;
  border-radius: var(--radius-sm);
}
.btn.icon-only {
  padding: 8px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
}

/* Form Controls */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
label small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: 0;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
input[disabled], select[disabled], textarea[disabled] {
  background-color: #f8fafc;
  color: var(--text-muted);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 80px; }

/* Cards & Layout */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.muted { color: var(--text-muted); }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
}
.brand-mark.small {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 16px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475467;
  white-space: nowrap;
}
.badge.COMPLETED, .badge.RETURNED, .badge.success {
  background: var(--success-light);
  color: var(--success-text);
}
.badge.REQUESTED, .badge.WAITING_PARTS, .badge.WAITING_PICKUP, .badge.INSPECTING, .badge.warning {
  background: var(--warning-light);
  color: var(--warning-text);
}
.badge.CANCELLED, .badge.REJECTED, .badge.danger {
  background: var(--danger-light);
  color: var(--danger-text);
}
.badge.REPAIRING, .badge.RECEIVED, .badge.info {
  background: var(--info-light);
  color: var(--info-text);
}

/* Tables */
.table-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  box-shadow: var(--shadow-sm);
  position: relative;
}
table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 2;
}
tr:hover td { background-color: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.money {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Toast */
#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f172a;
  color: #ffffff;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUpToast 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUpToast {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin: 14px 0;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert.success { background: var(--success-light); color: var(--success-text); border: 1px solid #a7f3d0; }
.alert.danger { background: var(--danger-light); color: var(--danger-text); border: 1px solid #fecaca; }
.alert.warning { background: var(--warning-light); color: var(--warning-text); border: 1px solid #fde68a; }

/* Login & Installer Shell */
.login-shell, .installer {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 80% 20%, rgba(20, 184, 166, 0.15), transparent 45%),
              radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.12), transparent 40%),
              var(--bg);
  padding: 20px;
}
.login-card, .install-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-card h1, .install-card h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 14px 0 4px;
  letter-spacing: -0.02em;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 28px;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-close {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-muted);
  background: #f1f5f9;
  font-size: 20px;
  transition: all 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }
.modal-header {
  margin-bottom: 20px;
  padding-right: 40px;
}
.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.modal-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* Form Grids */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 18px 0;
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Loading Spinner */
.loading {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Print Styles for Thermal Receipt */
@media print {
  body * { visibility: hidden; }
  #thermalReceipt, #thermalReceipt * { visibility: visible; }
  #thermalReceipt {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    margin: 0;
    padding: 8px 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    color: #000;
    background: #fff;
  }
  @page {
    size: 80mm auto;
    margin: 0;
  }
}
