:root {
  color-scheme: light;
  --page: #f5f1e8;
  --surface: #ffffff;
  --ink: #2c2c2c;
  --muted: #756f68;
  --brown: #3e2723;
  --accent: #d2bfa9;
  --border: #ddd1c2;
  --success: #24713c;
  --success-bg: #eaf7ee;
  --warning: #6b513b;
  --warning-bg: #efe1d2;
  --danger: #a12b35;
  --danger-bg: #fdebec;
  --shadow: 0 14px 36px rgba(62, 39, 35, 0.1);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--page); min-height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page);
  color: var(--ink);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.55; }
input, textarea, select {
  width: 100%;
  border: 1px solid #b9aa9a;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  font-size: 16px;
}
textarea { resize: vertical; }
label { display: block; margin: 14px 0 6px; font-weight: 750; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 {
  font-family: "Trebuchet MS", Arial, sans-serif;
  letter-spacing: -0.03em;
}
h1 { font-size: clamp(2.15rem, 8vw, 3rem); margin-bottom: 10px; }
h2 { font-size: 1.75rem; margin-bottom: 10px; }
h3 { font-size: 1.08rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.eyebrow {
  margin-bottom: 7px;
  color: var(--warning);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.12em;
}
.lead { font-size: 1.08rem; line-height: 1.55; color: var(--muted); }
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 9px 14px;
  background: var(--danger);
  color: #fff;
  text-align: center;
  font-weight: 750;
  font-size: 0.88rem;
}

.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at top right, rgba(210, 191, 169, 0.55), transparent 36%),
    var(--page);
}
.login-card {
  width: min(100%, 440px);
  padding: 36px 26px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo {
  display: block;
  margin: 0 auto 20px;
  border-radius: 28px;
}
.google-button {
  min-height: 44px;
  margin: 24px auto 12px;
  display: flex;
  justify-content: center;
}
.status-text {
  min-height: 22px;
  color: var(--muted);
  line-height: 1.45;
}
.privacy-note {
  margin: 20px auto 0;
  max-width: 340px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.app-shell { min-height: 100vh; padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: rgba(245, 241, 232, 0.94);
  border-bottom: 1px solid rgba(221, 209, 194, 0.9);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 12px; }
.brand div { display: grid; }
.brand span { color: var(--muted); font-size: 0.72rem; }
.brand strong { font-family: "Trebuchet MS", Arial, sans-serif; font-size: 1.25rem; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.quiet-button, .icon-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 13px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}
.icon-button { color: var(--danger); }

.identity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(100% - 28px, 920px);
  margin: 14px auto 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.identity-bar div { min-width: 0; display: grid; }
.identity-bar strong, .identity-bar span { overflow: hidden; text-overflow: ellipsis; }
.identity-bar div span { color: var(--muted); font-size: 0.78rem; }
.role-badge, .status-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.73rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-badge.success {
  background: var(--success-bg);
  color: var(--success);
}
.status-badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.main-nav {
  display: flex;
  gap: 8px;
  width: min(100%, 950px);
  margin: 0 auto;
  padding: 8px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.main-nav button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}
.main-nav button.active { background: var(--brown); color: #fff; }

.app-status {
  width: min(100% - 28px, 920px);
  margin: 8px auto;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--muted);
}
.app-status.error { border-color: #e7b6ba; background: var(--danger-bg); color: var(--danger); }
.app-status.success { border-color: #b7ddc1; background: var(--success-bg); color: var(--success); }

.page-section {
  display: none;
  width: min(100% - 28px, 920px);
  margin: 14px auto 0;
}
.page-section.active { display: block; }
.welcome-card, .security-card, .candidate-self-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(62, 39, 35, 0.05);
}
.welcome-card {
  color: #fff;
  background: linear-gradient(145deg, #3e2723, #684b3f);
}
.welcome-card .eyebrow, .welcome-card p { color: #f3e8dc; }
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.quick-card {
  min-height: 112px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 17px;
  background: var(--surface);
  text-align: left;
}
.quick-card strong { display: block; margin-bottom: 6px; font-size: 1.05rem; }
.quick-card span { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.security-card { box-shadow: none; }
.security-card p, .section-note { color: var(--muted); line-height: 1.55; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-heading h2 { margin-bottom: 0; }
.filter-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 260px);
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.filter-row label { margin: 0; }
.card-list { display: grid; gap: 12px; }
.empty-state {
  padding: 34px 18px;
  border: 1px dashed #b9aa9a;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}
.reservation-card, .candidate-card, .user-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.card-top h3 { margin: 0 0 4px; font-size: 1.15rem; }
.card-id { color: var(--muted); font-size: 0.76rem; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 14px;
  margin-top: 14px;
  font-size: 0.88rem;
}
.detail-grid div { min-width: 0; }
.detail-grid span { display: block; color: var(--muted); font-size: 0.72rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.card-actions button {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  background: #fff;
  font-weight: 750;
  font-size: 0.83rem;
}
.card-actions button.primary { background: var(--brown); border-color: var(--brown); color: #fff; }
.card-actions button.danger { color: var(--danger); border-color: #e1aeb4; }

.primary-button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--brown);
  color: #fff;
  font-weight: 800;
}
.panel-form {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}
.panel-form .primary-button { width: 100%; margin-top: 18px; }

.message-list {
  height: min(56vh, 560px);
  margin-top: 12px;
  padding: 14px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}
.message {
  width: min(86%, 560px);
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 14px 14px 14px 4px;
  background: var(--warning-bg);
}
.message.mine {
  margin-left: auto;
  border-radius: 14px 14px 4px 14px;
  background: var(--success-bg);
}
.message strong { display: block; margin-bottom: 3px; font-size: 0.75rem; }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.message time { display: block; margin-top: 4px; color: var(--muted); font-size: 0.66rem; }
.message-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 9px;
  margin-top: 10px;
}
.message-form label { margin: 0; }

.action-dialog {
  width: min(calc(100% - 24px), 540px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(44, 44, 44, 0.28);
}
.action-dialog::backdrop { background: rgba(44, 44, 44, 0.56); }
.action-dialog form, .action-dialog > div { position: relative; padding: 24px; }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  font-size: 1.45rem;
}
.action-summary {
  padding: 14px;
  border-radius: 14px;
  background: var(--page);
  font-size: 0.88rem;
  line-height: 1.55;
}
.action-dialog .primary-button { width: 100%; margin-top: 16px; }

@media (min-width: 760px) {
  .quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .reservation-card, .candidate-card, .user-card { padding: 20px 22px; }
}

@media (max-width: 520px) {
  .identity-bar { align-items: flex-start; }
  .identity-bar div { max-width: 72%; }
  .filter-row { grid-template-columns: 1fr; gap: 4px; }
  .detail-grid { grid-template-columns: 1fr; }
  .message-form { grid-template-columns: 1fr; }
  .message-form .primary-button { width: 100%; }
}

@media (display-mode: standalone) {
  #installButton { display: none !important; }
}
