:root {
  --ink: #171b1a;
  --ink-muted: #5b655f;
  --border: #e2e5e1;
  --bg: #f5f6f4;
  --teal: #0f6e5c;
  --teal-dark: #0b5c4d;
  --teal-tint: #eaf5f2;
  --white: #ffffff;
  --danger: #b02367;
  --danger-tint: #fce8f1;
  --success: #0f9d58;
  --success-tint: #e6f6ec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}
.topbar-brand { font-weight: 700; font-size: 16px; }
.topbar-nav { display: flex; gap: 16px; flex-grow: 1; margin-inline-start: 24px; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--ink-muted); }
.lang-switcher-label {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.lang-switcher {
  width: auto;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

/* RTL (Arabic): flip a handful of layouts that use a fixed left/right rather
   than a logical direction. Most of the app (flexbox, text-align defaults)
   mirrors automatically just from the <html dir="rtl"> attribute. */
[dir="rtl"] .tooth-actions,
[dir="rtl"] .job-order-instruction,
[dir="rtl"] .teeth-summary { text-align: inherit; }
[dir="rtl"] th { text-align: right; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--success-tint); color: var(--success); }
.alert-error { background: var(--danger-tint); color: var(--danger); }

.auth-card {
  max-width: 360px;
  margin: 60px auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}
.auth-card h1 { margin-top: 0; font-size: 20px; }

form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 4px; }
form input, form select, form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
form button, .btn {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--teal);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
form button:hover, .btn:hover { background: var(--teal-dark); }
.btn-secondary { background: var(--white); color: var(--ink); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; font-size: 14px; border-top: 1px solid var(--border); }
th { border-top: none; background: var(--bg); font-size: 12px; text-transform: uppercase; color: var(--ink-muted); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-neutral { background: #e7ebef; color: #52606d; }
.badge-progress { background: var(--teal-tint); color: var(--teal-dark); }
.badge-shipped { background: var(--success-tint); color: var(--success); }
.badge-warn { background: #fdf1dc; color: #b4530a; }

.card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }

/* Job-order-style forms (New case, and the printed job order) */
.job-order-form { max-width: 760px; }
.form-section { margin-bottom: 22px; }
.section-band {
  background: var(--teal);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 12px;
  border-radius: 8px 8px 0 0;
  margin-top: 0;
}
.form-section .form-grid,
.form-section > label:first-of-type { margin-top: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 4px 16px 16px;
}
.form-section .hint { color: var(--ink-muted); font-size: 13px; margin: 10px 0 0; }
.tooth-chart-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 16px;
}
.tooth-chart { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.tooth-row { display: flex; align-items: center; gap: 10px; }
.tooth-group { display: flex; gap: 1px; }
.tooth {
  width: 30px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: inherit;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 1px;
  gap: 2px;
}
/* Crown points toward the gap between the two rows, root points outward —
   so the number (read from the outer edge, like a real chart) sits above
   the tooth for the upper arch and below it for the lower arch. */
.tooth-row.upper-row .tooth { flex-direction: column-reverse; }
.tooth-row.lower-row .tooth { flex-direction: column; }
.tooth-svg {
  width: 26px;
  height: 40px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.tooth-num { font-size: 10px; font-weight: 700; line-height: 1; }
.tooth:hover { color: var(--teal); background: var(--teal-tint); }
.tooth.selected { color: var(--white); background: var(--teal); }
.tooth.selected .tooth-svg { fill: rgba(255, 255, 255, 0.18); }
.tooth-actions { margin-top: 10px; font-size: 13px; }
.tooth-actions a { cursor: pointer; }
.teeth-summary { color: var(--ink-muted); font-size: 13px; margin-top: 8px; text-align: center; min-height: 18px; }

.priority-options { display: flex; gap: 10px; margin-top: 4px; }
.priority-options label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-weight: 500 !important;
  margin: 0 !important;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
}
.priority-options input { width: auto !important; margin: 0; }
.priority-options label:has(input:checked) { border-color: var(--teal); background: var(--teal-tint); color: var(--teal-dark); }

.job-order-print { max-width: 400px; margin: 40px auto; text-align: center; border: 2px solid var(--ink); padding: 24px; background: var(--white); }
.job-order-header { margin-bottom: 12px; }
.job-order-header h2 { margin: 0 0 4px; }
.job-order-number { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; margin: 0; }
.job-order-fields { margin-bottom: 16px; }
.job-order-qr { display: flex; justify-content: center; margin: 16px auto; }
.job-order-teeth { margin: 12px 0; }
.job-order-print .tooth-chart { gap: 10px; }
.job-order-print .tooth-row { gap: 5px; }
.job-order-print .tooth-group { gap: 0; }
.job-order-print .tooth { width: 16px; padding: 1px 0; }
.job-order-print .tooth-svg { width: 15px; height: 22px; stroke-width: 1.4; }
.job-order-print .tooth-num { font-size: 6px; }
.job-order-instruction { color: var(--ink-muted); font-size: 13px; margin: 12px 0 0; }
@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .job-order-print { border: 2px solid #000; margin: 0 auto; }
}
