:root {
  color-scheme: light;
  --ink: #19312f;
  --muted: #6b7d7a;
  --surface: #ffffff;
  --surface-soft: #f2f8f6;
  --line: #dce9e5;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #d8f3ed;
  --warning: #b45309;
  --warning-soft: #fff1d6;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --shadow: 0 16px 40px rgba(25, 49, 47, 0.08);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #eef5f3;
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: rgba(255, 255, 255, 0.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 210px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: white; background: linear-gradient(135deg, #0f766e, #14b8a6); box-shadow: 0 8px 18px rgba(15, 118, 110, .2); }
.brand-mark svg { width: 24px; height: 24px; }
.brand strong { display: block; letter-spacing: .03em; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.nav-tabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
.nav-tab { border: 0; border-radius: 10px; padding: 10px 13px; color: var(--muted); background: transparent; white-space: nowrap; }
.nav-tab:hover, .nav-tab.active { color: var(--primary-dark); background: var(--primary-soft); font-weight: 700; }

.user-menu { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--primary-dark); background: var(--primary-soft); font-weight: 800; }
.user-menu small { display: block; color: var(--muted); font-size: 11px; }
.user-menu button { border: 0; color: var(--muted); background: transparent; padding: 8px; }

.main { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px, 4vw, 40px); line-height: 1.15; letter-spacing: -.04em; }
h2 { margin-bottom: 5px; font-size: 20px; }
h3 { margin-bottom: 8px; font-size: 16px; }
.page-heading p, .subtle { margin-bottom: 0; color: var(--muted); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { border: 1px solid var(--line); border-radius: 20px; padding: 24px; background: var(--surface); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.card-head p { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.hero-card { position: relative; overflow: hidden; min-height: 220px; color: white; border: 0; background: linear-gradient(135deg, #0f766e 0%, #115e59 55%, #143f3e 100%); }
.hero-card::after { content: ""; position: absolute; width: 270px; height: 270px; right: -50px; top: -92px; border: 28px solid rgba(255, 255, 255, .1); border-radius: 50%; }
.hero-card .eyebrow { color: #a7f3d0; }
.hero-card p { max-width: 560px; color: rgba(255,255,255,.78); }
.hero-card .hero-icon { position: absolute; right: 60px; bottom: 22px; width: 100px; height: 100px; opacity: .18; }

.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 11px; color: var(--ink); background: #f1f5f4; font-weight: 700; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); filter: brightness(.98); }
.btn-primary { color: white; background: var(--primary); box-shadow: 0 8px 18px rgba(15, 118, 110, .2); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { color: var(--primary-dark); border-color: var(--line); background: white; }
.btn-danger { color: var(--danger); background: var(--danger-soft); }
.btn-small { min-height: 34px; padding: 7px 11px; border-radius: 9px; font-size: 13px; }
.btn:disabled { cursor: not-allowed; opacity: .52; transform: none; }
.hero-card .btn-ghost { border-color: rgba(255,255,255,.35); color: white; background: rgba(255,255,255,.12); }

.metric { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 8px; font-size: 30px; font-weight: 850; letter-spacing: -.04em; }
.metric-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: var(--primary); background: var(--primary-soft); }
.metric-icon.warning { color: var(--warning); background: var(--warning-soft); }

.scanner-card { border: 1px solid #bde6db; background: linear-gradient(180deg, #f8fffd, #effaf7); }
.scanner-box { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 14px; border: 1px dashed #9cd6c8; border-radius: 15px; background: white; }
.scanner-box input { flex: 1; min-width: 130px; border: 0; outline: 0; }
.scanner-box input::placeholder { color: #a0b1ae; }
.scanner-hint { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.vehicle-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.vehicle-meta { display: flex; align-items: center; gap: 13px; min-width: 0; }
.vehicle-icon { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border-radius: 14px; color: var(--primary-dark); background: var(--primary-soft); }
.vehicle-icon svg { width: 27px; height: 27px; }
.vehicle-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vehicle-meta span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-available, .status-returned, .status-closed { color: #087443; background: #dff7e9; }
.status-in_use, .status-processing { color: #075985; background: #e0f2fe; }
.status-pending, .status-reported { color: var(--warning); background: var(--warning-soft); }
.status-maintenance, .status-cancelled, .status-inactive { color: var(--danger); background: var(--danger-soft); }

.list { display: grid; gap: 10px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.list-row:first-child { padding-top: 0; }
.list-main strong { display: block; font-size: 14px; }
.list-main span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.empty { display: grid; place-items: center; min-height: 160px; color: var(--muted); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 12px; border-radius: 14px; color: var(--primary); background: var(--primary-soft); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field-full { grid-column: 1 / -1; }
.field label { color: #4d6662; font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); outline: 0; background: white; }
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #67bdb0; box-shadow: 0 0 0 3px rgba(20, 184, 166, .12); }
.field-note { color: var(--muted); font-size: 11px; font-weight: 400; }
.radio-group { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-option { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 13px; }
.radio-option:has(input:checked) { border-color: #76cfc1; color: var(--primary-dark); background: var(--primary-soft); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; white-space: nowrap; }
th { color: var(--muted); background: #f7fbfa; font-size: 12px; font-weight: 800; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfefd; }
.link-button { padding: 0; border: 0; color: var(--primary); background: transparent; font-weight: 800; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; padding: 15px; border-radius: 14px; background: var(--surface-soft); }
.filter-bar .field { min-width: 145px; flex: 1; }
.filter-bar .field input, .filter-bar .field select { min-height: 38px; }

.exception-card { padding: 16px; border: 1px solid #f0dbb3; border-radius: 14px; background: #fffdf8; }
.exception-card + .exception-card { margin-top: 10px; }
.exception-top { display: flex; justify-content: space-between; gap: 15px; }
.exception-photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.exception-photo-grid img { width: 84px; height: 64px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: radial-gradient(circle at 20% 10%, #d5f3ec 0, transparent 35%), #eef5f3; }
.login-card { width: min(450px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 34px; }
.login-card h1 { font-size: 30px; }
.login-card .subtle { margin-bottom: 24px; }
.login-form { display: grid; gap: 15px; }
.login-form .btn { width: 100%; margin-top: 5px; }
.demo-note { margin-top: 18px; padding: 12px; border-radius: 11px; color: var(--muted); background: var(--surface-soft); font-size: 12px; line-height: 1.7; }
.error-text { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(14, 39, 37, .48); }
.modal { width: min(600px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 20px; background: white; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.modal-head { display: flex; justify-content: space-between; gap: 15px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; color: var(--muted); background: var(--surface-soft); }
.modal-body { padding: 22px; }
.camera-frame { position: relative; overflow: hidden; aspect-ratio: 4 / 3; margin-bottom: 16px; border-radius: 14px; background: #19312f; }
.camera-frame video { display: block; width: 100%; height: 100%; object-fit: cover; }
.camera-frame .scan-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #5eead4; box-shadow: 0 0 15px #5eead4; }
.camera-fallback { padding: 20px; color: white; text-align: center; }
.qr-photo-picker { display: grid; gap: 8px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid #bde6db; border-radius: 14px; background: #f3fbf8; }
.qr-photo-picker label { color: var(--primary-dark); font-weight: 800; }
.qr-photo-picker input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.qr-photo-picker span { color: var(--muted); font-size: 12px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; max-width: min(360px, calc(100% - 44px)); padding: 13px 16px; border-radius: 12px; color: white; background: #19312f; box-shadow: 0 14px 30px rgba(0,0,0,.2); animation: toast-in .2s ease-out; }
.toast.success { background: #087443; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 18px; }
  .brand { min-width: 0; }
  .nav-tabs { order: 3; width: 100%; }
  .user-menu { margin-left: auto; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .main { width: min(100% - 24px, 1240px); padding-top: 24px; }
  .page-heading { display: block; }
  .page-heading .action-row { margin-top: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .card { padding: 18px; border-radius: 16px; }
  .hero-card { min-height: 245px; }
  .hero-card .hero-icon { right: 20px; bottom: 22px; }
  .scanner-box { align-items: stretch; flex-wrap: wrap; }
  .scanner-box input { flex-basis: 100%; min-height: 34px; }
  .vehicle-banner { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .login-card { padding: 26px 20px; }
  .topbar { min-height: auto; }
  .brand span { display: none; }
  .user-menu .user-copy { display: none; }
}
