:root {
    --bg: #f5f7fb;
    --card: #fff;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --danger: #dc2626;
    --ok: #16a34a;
    --warn: #d97706;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--primary); text-decoration: none; }
.topbar { background: #111827; color: #fff; padding: 12px 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; margin-right: auto; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 10px; }
.topbar nav a { color: #fff; background: rgba(255,255,255,.1); padding: 7px 10px; border-radius: 8px; font-size: 14px; }
.userbox { font-size: 13px; color: #d1d5db; }
.container { max-width: 1280px; margin: 24px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: 0 6px 18px rgba(17,24,39,.06); margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: block; font-weight: 700; margin-bottom: 6px; }
input, select, textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 10px; padding: 10px 11px; font-size: 15px; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--primary); color: #fff; cursor: pointer; display: inline-block; font-weight: 700; }
.btn-secondary { background: #374151; }
.btn-danger { background: var(--danger); }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; font-size: 14px; }
th { background: #f3f4f6; white-space: nowrap; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #e5e7eb; font-size: 12px; font-weight: 700; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.scheduled { background: #dbeafe; color: #1e40af; }
.badge.completed { background: #dcfce7; color: #166534; }
.badge.canceled { background: #fee2e2; color: #991b1b; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; background: #dbeafe; }
.alert-success { background: #dcfce7; }
.alert-error { background: #fee2e2; }
.alert-warning { background: #fef3c7; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat strong { display: block; font-size: 28px; }
.small { color: var(--muted); font-size: 13px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; margin-top: 26px; }
.checkbox-line input { width: auto; }
.login-wrap { max-width: 420px; margin: 60px auto; }
.print-only { display: none; }

@media (max-width: 800px) {
    .grid-2, .grid-3, .stats { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; }
    .topbar nav a { font-size: 13px; padding: 6px 8px; }
}

@media print {
    @page { size: A4 landscape; margin: 9mm; }
    body { background: #fff; font-size: 12px; }
    .topbar, .no-print, .form-actions, .alert { display: none !important; }
    .container { max-width: none; margin: 0; padding: 0; }
    .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
    .print-only { display: block; }
    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; page-break-after: auto; }
    th, td { border: 1px solid #111; padding: 6px; }
    .print-title { font-size: 22px; font-weight: 900; text-align: center; margin: 0 0 8px; }
    .print-meta { display: flex; justify-content: space-between; margin-bottom: 8px; }
    .signature-box { height: 58px; }
}
