:root {
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-2: #eef4f5;
  --ink: #17313a;
  --muted: #607780;
  --line: #d8e2e5;
  --brand: #123f4d;
  --brand-2: #176578;
  --success: #217a52;
  --warning: #9b6700;
  --danger: #a83b3b;
  --shadow: 0 12px 35px rgba(23, 49, 58, .09);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100%; color: var(--ink); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.topbar { position: sticky; top: 0; z-index: 50; height: 68px; padding: 10px 16px; display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--brand); color: white; font-weight: 800; letter-spacing: .03em; }
.brand strong, .brand small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--muted); font-size: .76rem; margin-top: 2px; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 14px; background: var(--surface-2); font-size: 1.35rem; cursor: pointer; }
.connection-banner { position: sticky; top: 68px; z-index: 45; padding: 9px 16px; text-align: center; background: #fff2c8; color: #684600; border-bottom: 1px solid #ead79c; font-size: .86rem; }
.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 18px 16px calc(94px + var(--safe-bottom)); }
.app-shell.wide { width: min(1360px, 100%); }
.loading-card, .card, .login-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.loading-card { min-height: 190px; display: grid; place-items: center; align-content: center; gap: 10px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #d9e6e9; border-top-color: var(--brand-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-wrap { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.login-card { width: min(560px, 100%); padding: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 5vw, 2.35rem); line-height: 1.05; margin-bottom: 12px; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; }
p { color: var(--muted); line-height: 1.55; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 14px; }
.section-heading h1, .section-heading h2 { margin-bottom: 4px; }
.section-heading p { margin-bottom: 0; }
.badges, .chips { display: flex; flex-wrap: wrap; gap: 7px; }
.badge, .chip { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 700; }
.badge.success { background: #e3f4eb; color: var(--success); }
.badge.warning { background: #fff1cf; color: var(--warning); }
.badge.danger { background: #fbe2e2; color: var(--danger); }
.badge.info { background: #e1f1f5; color: var(--brand-2); }
.notice { padding: 13px 14px; border-radius: 13px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); line-height: 1.45; font-size: .9rem; }
.notice.warning { background: #fff8df; border-color: #ead99d; color: #725300; }
.notice.danger { background: #fff0f0; border-color: #efc1c1; color: #8b3030; }
.user-list { display: grid; gap: 10px; margin-top: 18px; }
.user-button { width: 100%; border: 1px solid var(--line); background: white; border-radius: 16px; padding: 13px 14px; display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; text-align: left; cursor: pointer; }
.user-button:hover { border-color: var(--brand-2); background: #f7fbfc; }
.user-button strong, .user-button small { display: block; }
.user-button small { color: var(--muted); margin-top: 3px; }
.avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: white; font-weight: 800; }
.login-divider { margin: 22px 0 8px; color: var(--muted); font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card { padding: 16px; border: 1px solid var(--line); background: white; border-radius: 16px; }
.summary-card strong { display: block; font-size: 1.9rem; line-height: 1; margin-bottom: 7px; }
.summary-card span { color: var(--muted); font-size: .86rem; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { padding: 18px; }
.card.flat { box-shadow: none; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-header h2, .card-header h3, .card-header p { margin-bottom: 0; }
.task-list, .record-list, .simple-list { display: grid; gap: 10px; }
.task-card, .record-card, .environment-card, .activity-card { width: 100%; border: 1px solid var(--line); background: white; border-radius: 15px; padding: 14px; text-align: left; cursor: pointer; }
.task-card:hover, .record-card:hover, .environment-card:hover, .activity-card:hover { border-color: #92bac3; background: #f9fcfd; }
.task-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.task-card strong, .record-card strong, .environment-card strong, .activity-card strong { display: block; }
.task-card small, .record-card small, .environment-card small, .activity-card small { color: var(--muted); display: block; margin-top: 4px; line-height: 1.35; }
.activity-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.activity-card { min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; }
.activity-card .activity-icon { font-size: 1.4rem; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.status-row:last-child { border-bottom: 0; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #bdc9cc; }
.status-dot.done { background: var(--success); }
.status-dot.pending { background: #d39a28; }
.button { min-height: 46px; border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button.primary { background: var(--brand); color: white; }
.button.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.button.success { background: var(--success); color: white; }
.button.warning { background: #f6c85f; color: #4e3500; }
.button.danger { background: var(--danger); color: white; }
.button.ghost { background: transparent; color: var(--brand-2); }
.button.small { min-height: 36px; padding: 7px 11px; border-radius: 11px; font-size: .84rem; }
.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.actions.end { justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 800; font-size: .86rem; margin-bottom: 7px; }
.input, .select, .textarea { width: 100%; border: 1px solid #c9d8dc; border-radius: 13px; background: white; color: var(--ink); padding: 11px 12px; outline: 0; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(23,101,120,.12); }
.textarea { min-height: 92px; resize: vertical; }
.help-text { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.checkbox-list { display: grid; gap: 9px; }
.check-row { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; }
.check-row small { display: block; color: var(--muted); margin-top: 3px; }
.segmented { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.segmented button { border: 1px solid var(--line); background: white; border-radius: 11px; padding: 9px; font-weight: 700; cursor: pointer; }
.segmented button.active { background: var(--brand); color: white; border-color: var(--brand); }
.bottom-nav { position: fixed; z-index: 60; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(620px, calc(100% - 20px)); display: grid; grid-template-columns: repeat(4,1fr); padding: 7px; padding-bottom: calc(7px + var(--safe-bottom)); border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.97); box-shadow: 0 14px 40px rgba(20,50,60,.18); backdrop-filter: blur(12px); }
.bottom-nav button { border: 0; background: transparent; border-radius: 13px; padding: 8px 5px; color: var(--muted); font-size: .74rem; font-weight: 800; cursor: pointer; }
.bottom-nav button span { display: block; font-size: 1.2rem; margin-bottom: 2px; }
.bottom-nav button.active { color: var(--brand); background: var(--surface-2); }
.management-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px; scrollbar-width: thin; }
.management-tabs button { white-space: nowrap; border: 1px solid var(--line); background: white; border-radius: 999px; padding: 9px 13px; font-weight: 800; color: var(--muted); cursor: pointer; }
.management-tabs button.active { background: var(--brand); color: white; border-color: var(--brand); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: white; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: #eef4f5; font-size: .77rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td { font-size: .88rem; }
.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed #bdd0d5; border-radius: 14px; background: rgba(255,255,255,.65); }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(10,30,37,.58); display: grid; align-items: end; padding: 14px; }
.modal { width: min(720px, 100%); max-height: 92vh; overflow: auto; margin: 0 auto; background: white; border-radius: 22px; box-shadow: 0 25px 70px rgba(0,0,0,.27); }
.modal-header { position: sticky; top: 0; z-index: 2; padding: 17px 18px; background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-header h2 { margin: 0; }
.modal-body { padding: 18px; }
.modal-close { width: 38px; height: 38px; border: 0; background: var(--surface-2); border-radius: 12px; cursor: pointer; }
.toast { position: fixed; z-index: 150; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translateX(-50%); width: min(520px, calc(100% - 30px)); padding: 13px 15px; border-radius: 14px; color: white; background: #263b43; box-shadow: var(--shadow); text-align: center; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.qr-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.qr-card { padding: 16px; background: white; border: 1px solid var(--line); border-radius: 16px; text-align: center; }
.qr-code { min-height: 190px; display: grid; place-items: center; margin: 12px auto; }
.qr-code img, .qr-code canvas { max-width: 100%; height: auto; }
.code-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; letter-spacing: .05em; }
.pending-send { border-left: 5px solid var(--warning); }
@media (max-width: 800px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.two, .grid.three, .activity-grid, .qr-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .login-card { padding: 22px 17px; }
}
@media (min-width: 760px) {
  .modal-backdrop { align-items: center; }
}
@media print {
  .no-print, .topbar, .bottom-nav, .toast, .modal-backdrop { display: none !important; }
  body, html { background: white; }
  .app-shell { padding: 0; width: 100%; }
  .qr-card { break-inside: avoid; box-shadow: none; }
}
