:root {
  --ink: #17202e;
  --muted: #70798a;
  --line: #e8ebf0;
  --paper: #ffffff;
  --canvas: #f4f6f9;
  --navy: #17263e;
  --blue: #4a67ff;
  --blue-soft: #eef1ff;
  --teal: #16a085;
  --teal-soft: #e8f8f4;
  --orange: #ef9a3e;
  --orange-soft: #fff4e7;
  --red: #e05b63;
  --red-soft: #fff0f1;
  --shadow: 0 16px 50px rgba(29, 43, 67, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.eyebrow {
  margin: 0 0 8px;
  color: #7f8ca1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}
.muted { color: var(--muted); }
.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #455fff, #7a8bff);
  box-shadow: 0 12px 28px rgba(74, 103, 255, .25);
  font-size: 24px;
  font-weight: 900;
}
.brand-mark-small { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; }

/* Authentication */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 12% 10%, rgba(90, 112, 255, .16), transparent 32%),
    radial-gradient(circle at 90% 90%, rgba(22, 160, 133, .12), transparent 34%),
    #f5f7fb;
}
.auth-shell {
  width: min(980px, 100%);
  min-height: 610px;
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 30px;
  background: var(--paper);
  box-shadow: 0 35px 100px rgba(34, 49, 80, .16);
}
.auth-shell-compact { min-height: 540px; }
.auth-brand {
  position: relative;
  padding: 70px;
  color: #fff;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(28, 42, 70, .98), rgba(42, 62, 101, .96)),
    var(--navy);
}
.auth-brand::after {
  content: "";
  position: absolute;
  width: 340px;
  height: 340px;
  right: -130px;
  bottom: -150px;
  border: 64px solid rgba(255,255,255,.055);
  border-radius: 50%;
}
.auth-brand .eyebrow { margin-top: 72px; color: #a9b6cf; }
.auth-brand h1 { margin: 0; font-size: clamp(42px, 5vw, 62px); line-height: 1.06; letter-spacing: -.05em; }
.auth-description { max-width: 360px; margin: 25px 0 32px; color: #c8d1e2; font-size: 16px; line-height: 1.7; }
.auth-feature-list { display: flex; flex-wrap: wrap; gap: 8px; }
.auth-feature-list span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 99px; color: #d8dff0; font-size: 12px; }
.auth-card { align-self: center; padding: 60px; }
.auth-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.04em; }
.auth-card > div:first-child { margin-bottom: 28px; }
.auth-form { display: grid; gap: 18px; }
.auth-form label { display: grid; gap: 8px; color: #4f5868; font-size: 13px; font-weight: 700; }
.auth-form input, .search-input {
  width: 100%;
  border: 1px solid #dfe4ec;
  border-radius: 13px;
  outline: none;
  background: #fbfcfe;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.auth-form input { height: 50px; padding: 0 15px; }
.auth-form input:focus, .search-input:focus { border-color: #8192ff; background: #fff; box-shadow: 0 0 0 4px rgba(74,103,255,.1); }
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  padding: 0 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s, opacity .16s, box-shadow .16s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: wait; transform: none; }
.button-primary { color: #fff; background: var(--blue); box-shadow: 0 10px 25px rgba(74,103,255,.22); }
.button-secondary { color: var(--blue); background: var(--blue-soft); }
.button-success { color: #0c7a67; background: var(--teal-soft); }
.button-danger { color: #c94d56; background: var(--red-soft); }
.button-ghost { color: #616b7c; background: #f2f4f7; }
.button-small { min-height: 34px; padding: 0 11px; border-radius: 9px; font-size: 12px; }
.button-block { width: 100%; margin-top: 4px; }
.auth-footnote { margin: 22px 0 0; color: #8b93a1; font-size: 12px; line-height: 1.6; }
.flash { margin-bottom: 18px; padding: 12px 14px; border-radius: 11px; font-size: 13px; }
.flash-error { color: #a63d45; background: var(--red-soft); }
.flash-success { color: #087462; background: var(--teal-soft); }
.single-message-card { width: min(520px, 100%); padding: 54px; border-radius: 28px; background: #fff; box-shadow: var(--shadow); }
.single-message-card .eyebrow { margin-top: 35px; }
.single-message-card h1 { margin: 0 0 15px; font-size: 34px; letter-spacing: -.04em; }
.single-message-card .button { margin-top: 18px; }

/* Dashboard shell */
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(20px, 4vw, 54px);
  border-bottom: 1px solid rgba(222, 226, 234, .82);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(18px);
}
.topbar-brand, .topbar-actions, .user-chip { display: flex; align-items: center; }
.topbar-brand { gap: 12px; }
.topbar-brand div { display: grid; gap: 2px; }
.topbar-brand strong { font-size: 15px; }
.topbar-brand div span { color: #8a93a2; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.topbar-actions { gap: 13px; }
.connection-state { padding: 7px 10px; border-radius: 99px; color: #778091; background: #f1f3f6; font-size: 11px; font-weight: 800; }
.connection-state.is-online { color: #087966; background: var(--teal-soft); }
.connection-state.is-error { color: #bd4851; background: var(--red-soft); }
.user-chip { gap: 9px; padding: 6px 10px 6px 6px; border: 1px solid var(--line); border-radius: 99px; background: #fff; }
.user-avatar { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; color: #fff; background: var(--navy); font-size: 12px; font-weight: 900; }
.user-chip div { display: grid; gap: 1px; }
.user-chip strong { font-size: 11px; }
.user-chip div span { color: #9199a7; font-size: 9px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 11px; color: #6d7685; background: #fff; cursor: pointer; }
.dashboard-shell { width: min(1540px, 100%); margin: 0 auto; padding: 30px clamp(18px, 4vw, 54px) 60px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.hero-row h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.055em; }
.hero-row .muted { margin: 0; }
.operation-toggles { display: flex; align-items: stretch; gap: 9px; }
.checker-toggle-group { display: flex; align-items: center; gap: 12px; padding: 10px 13px 10px 15px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 8px 28px rgba(36,49,72,.05); }
.checker-title { min-width: 105px; display: grid; gap: 2px; }
.checker-title strong { font-size: 12px; }
.checker-title small { color: #8a93a1; font-size: 9px; }
.account-toggle { display: flex; align-items: center; gap: 6px; color: #596476; font-size: 10px; font-weight: 800; cursor: pointer; }
.account-toggle input { position: absolute; opacity: 0; }
.account-toggle i { position: relative; width: 34px; height: 20px; border-radius: 99px; background: #ced3dc; transition: background .2s; }
.account-toggle i::after { content: ""; position: absolute; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s; }
.account-toggle input:checked + i { background: var(--blue); }
.account-toggle input:checked + i::after { transform: translateX(14px); }
.account-toggle input:disabled + i { opacity: .55; }
.tracking-toggle { display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 8px 28px rgba(36,49,72,.05); cursor: pointer; }
.tracking-toggle > span { display: grid; gap: 2px; }
.tracking-toggle strong { font-size: 12px; }
.tracking-toggle small { color: #8a93a1; font-size: 9px; }
.tracking-toggle input { position: absolute; opacity: 0; }
.tracking-toggle i { position: relative; width: 42px; height: 24px; border-radius: 99px; background: #ced3dc; transition: background .2s; }
.tracking-toggle i::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s; }
.tracking-toggle input:checked + i { background: var(--teal); }
.tracking-toggle input:checked + i::after { transform: translateX(18px); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 8px; }
.metric-card { min-height: 72px; display: flex; align-items: center; gap: 12px; padding: 13px 17px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 7px 22px rgba(31,46,70,.04); }
.metric-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 12px; font-size: 15px; font-weight: 900; }
.metric-card > div:last-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; }
.metric-card span { width: 100%; color: #7f8897; font-size: 9px; font-weight: 700; }
.metric-card strong { font-size: 22px; letter-spacing: -.04em; }
.metric-card small { color: #929aa7; font-size: 9px; }
.metric-away .metric-icon { color: var(--blue); background: var(--blue-soft); }
.metric-qr .metric-icon { color: var(--teal); background: var(--teal-soft); }
.metric-warn .metric-icon { color: var(--orange); background: var(--orange-soft); }
.metric-bot .metric-icon { color: #805bd7; background: #f3edff; }
.metric-bot strong { font-size: 14px; }
.metric-bot small { width: 100%; }

.primary-grid, .history-grid { display: grid; grid-template-columns: .78fr 1.42fr; gap: 14px; margin-top: 14px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.panel-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 20px; border-bottom: 1px solid #edf0f4; }
.panel-header h2 { margin: 0; font-size: 18px; letter-spacing: -.035em; }
.panel-header .eyebrow { margin-bottom: 4px; font-size: 9px; }
.count-pill { min-width: 29px; height: 29px; display: grid; place-items: center; padding: 0 8px; border-radius: 99px; color: var(--blue); background: var(--blue-soft); font-size: 11px; font-weight: 900; }
.away-list { min-height: 360px; padding: 10px 20px 18px; }
.qr-list { min-height: 360px; max-height: 560px; overflow: auto; scrollbar-gutter: stable; }
.empty-state { min-height: 320px; display: grid; place-items: center; align-content: center; gap: 8px; color: #9ba3b0; text-align: center; }
.empty-state-icon { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 20px; background: #f4f6f9; font-size: 24px; }
.empty-state strong { color: #667082; font-size: 14px; }
.empty-state span { font-size: 11px; }

.away-item { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 18px 0; border-bottom: 1px solid #eff1f4; }
.away-item:last-child { border-bottom: 0; }
.student-avatar { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(135deg, #7284a3, #34435c); font-size: 12px; font-weight: 900; }
.away-main { min-width: 0; }
.away-title, .qr-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.away-title strong, .qr-title-line strong { font-size: 13px; }
.away-content { margin: 5px 0 0; overflow: hidden; color: #7b8493; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.away-timer { text-align: right; }
.away-timer strong { display: block; font-variant-numeric: tabular-nums; font-size: 17px; }
.away-timer small { color: #8b94a2; font-size: 9px; }
.away-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }

.status-badge, .type-badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 9px; border-radius: 99px; font-size: 9px; font-weight: 900; }
.status-waiting, .status-watching, .status-pending { color: #3c5be0; background: var(--blue-soft); }
.status-camera_requested, .status-reserved { color: #bd6f20; background: var(--orange-soft); }
.status-qr_requested, .status-cancelled { color: #c44851; background: var(--red-soft); }
.status-returned, .status-delivered, .status-outing_departure_sent, .status-outing_departure_done, .status-outing_return_sent, .status-completed { color: #087561; background: var(--teal-soft); }
.type-absence { color: #d1454f; background: #ffebed; }
.type-late { color: #b2761c; background: #fff3dc; }
.type-early_leave { color: #c8792c; background: #fff0e5; }
.type-outing { color: #4c63d7; background: #edf0ff; }

.qr-ops-table { min-width: 780px; table-layout: fixed; }
.qr-ops-table thead { position: sticky; z-index: 4; top: 0; background: #fff; box-shadow: 0 1px 0 #edf0f4; }
.qr-ops-table th:nth-child(1) { width: 16%; }
.qr-ops-table th:nth-child(2) { width: 9%; }
.qr-ops-table th:nth-child(3) { width: 20%; }
.qr-ops-table th:nth-child(4) { width: 14%; }
.qr-ops-table th:nth-child(5) { width: 15%; }
.qr-ops-table th:nth-child(6) { width: 20%; }
.qr-ops-table th:nth-child(7) { width: 6%; }
.qr-ops-table th, .qr-ops-table td { padding: 11px 9px; }
.student-cell, .reason-cell { overflow: hidden; text-overflow: ellipsis; }
.student-cell { color: #303b4c; font-weight: 850; }
.schedule-cell { font-variant-numeric: tabular-nums; }
.schedule-date, .schedule-time { display: block; }
.schedule-date { color: #687384; font-weight: 800; }
.schedule-time { margin-top: 2px; color: #99a1ad; font-size: 9px; }
.qr-row-actions { display: flex; align-items: center; gap: 5px; }
.row-action, .menu-action, .history-more { border: 0; font-weight: 800; cursor: pointer; }
.row-action { min-height: 29px; padding: 0 8px; border-radius: 8px; white-space: nowrap; font-size: 9px; }
.row-action-primary { color: #fff; background: var(--blue); }
.row-action-complete { color: #087561; background: var(--teal-soft); }
.row-action-reserve { color: #3f5bdd; background: var(--blue-soft); }
.row-action-reserved { display: inline-flex; align-items: center; color: #bd6f20; background: var(--orange-soft); }
.action-finished { color: #9099a7; font-size: 9px; font-weight: 800; }
.action-menu { position: relative; }
.action-menu summary { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; color: #667183; background: #f1f3f6; cursor: pointer; list-style: none; font-weight: 900; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu-panel { position: absolute; z-index: 12; top: 34px; right: 0; width: 108px; display: grid; overflow: hidden; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 14px 35px rgba(20,34,55,.18); }
.menu-action { min-height: 31px; padding: 0 9px; border-radius: 7px; color: #566172; background: #fff; text-align: left; font-size: 9px; }
.menu-action:hover { background: #f4f6f9; }
.menu-action-danger { color: #ca4d56; }

.history-panel { min-height: 420px; }
.table-tools { width: min(190px, 45%); }
.table-tools-wide { width: min(300px, 56%); display: grid; grid-template-columns: 86px 1fr; gap: 7px; }
.search-input, .history-range { height: 34px; padding: 0 10px; border: 1px solid #dfe4ec; border-radius: 10px; color: #596374; background: #fbfcfe; font-size: 10px; outline: none; }
.history-range { cursor: pointer; }
.table-scroll { overflow: auto; padding: 0 22px 18px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 13px 10px; color: #8a93a2; font-size: 9px; text-align: left; letter-spacing: .04em; }
td { padding: 13px 10px; border-top: 1px solid #f0f2f5; color: #556071; font-size: 10px; }
td.cell-content { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.table-link { color: var(--blue); font-weight: 800; }
.table-empty { height: 180px; color: #9aa2af; text-align: center; }
.history-footer { display: flex; justify-content: center; padding: 0 20px 18px; }
.history-more { min-height: 34px; padding: 0 16px; border-radius: 10px; color: var(--blue); background: var(--blue-soft); font-size: 10px; }

.activity-panel { margin-top: 18px; }
.activity-note { color: #929aa7; font-size: 10px; }
.activity-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 26px; padding: 8px 24px 22px; }
.activity-item { min-width: 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #f0f2f5; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.activity-item div { min-width: 0; display: flex; gap: 6px; overflow: hidden; }
.activity-item strong, .activity-item span, .activity-item time { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.activity-item span { color: #758092; }
.activity-item time { color: #9ca4b0; }

.edit-dialog { width: min(580px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 22px; color: var(--ink); background: #fff; box-shadow: 0 35px 100px rgba(17, 29, 49, .28); }
.edit-dialog::backdrop { background: rgba(20, 30, 48, .46); backdrop-filter: blur(3px); }
.edit-form header, .edit-form footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.edit-form header { padding: 24px 26px 19px; border-bottom: 1px solid var(--line); }
.edit-form h2 { margin: 0; font-size: 21px; letter-spacing: -.04em; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 10px; color: #7b8492; background: #f2f4f7; font-size: 22px; cursor: pointer; }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 22px 26px 10px; }
.edit-fields label { display: grid; gap: 7px; }
.edit-fields label span { color: #596374; font-size: 11px; font-weight: 800; }
.edit-fields input, .edit-fields select { width: 100%; height: 43px; padding: 0 12px; border: 1px solid #dfe4ec; border-radius: 11px; outline: none; color: var(--ink); background: #fbfcfe; }
.edit-fields input:focus, .edit-fields select:focus { border-color: #8192ff; box-shadow: 0 0 0 4px rgba(74,103,255,.1); }
.field-wide { grid-column: 1 / -1; }
.dialog-note { margin: 5px 26px 18px; color: #939ba8; font-size: 10px; }
.edit-form footer { justify-content: flex-end; padding: 0 26px 24px; }

.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: 360px; padding: 14px 16px; border-radius: 13px; color: #fff; background: #202c3e; box-shadow: 0 18px 50px rgba(16,28,46,.25); font-size: 12px; font-weight: 700; opacity: 0; transform: translateY(18px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #b9434d; }
.skeleton-box:empty { margin: 24px; min-height: 300px; border-radius: 16px; background: linear-gradient(90deg, #f5f6f8 25%, #eceff3 37%, #f5f6f8 63%); background-size: 400% 100%; animation: skeleton 1.4s infinite; }
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: 0 0; } }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .primary-grid, .history-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .auth-page { padding: 14px; }
  .auth-shell { min-height: 0; grid-template-columns: 1fr; }
  .auth-brand { padding: 36px; }
  .auth-brand .eyebrow { margin-top: 35px; }
  .auth-brand h1 { font-size: 38px; }
  .auth-feature-list { display: none; }
  .auth-card { padding: 36px; }
  .topbar { padding: 10px 16px; }
  .topbar-brand div span, .connection-state { display: none; }
  .user-chip div { display: none; }
  .user-chip { padding-right: 6px; }
  .dashboard-shell { padding: 28px 14px 50px; }
  .hero-row { align-items: stretch; flex-direction: column; }
  .operation-toggles { flex-direction: column; }
  .checker-toggle-group { justify-content: space-between; }
  .tracking-toggle { justify-content: space-between; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 68px; padding: 12px; gap: 9px; }
  .metric-icon { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; }
  .metric-card strong { font-size: 20px; }
  .metric-bot strong { font-size: 13px; }
  .panel-header { padding: 19px; }
  .away-list { padding: 8px 19px 18px; }
  .away-item { grid-template-columns: auto 1fr; }
  .away-timer { grid-column: 2; text-align: left; }
  .history-grid { display: block; }
  .history-panel { margin-top: 18px; }
  .table-tools { width: 48%; }
  .table-tools-wide { width: 58%; grid-template-columns: 78px 1fr; }
  .table-scroll { padding: 0 12px 15px; }
  .activity-list { grid-template-columns: 1fr; padding-inline: 19px; }
  .edit-fields { grid-template-columns: 1fr; padding-inline: 20px; }
  .field-wide { grid-column: auto; }
  .edit-form header { padding-inline: 20px; }
  .edit-form footer { padding-inline: 20px; }
}
