:root {
  --cyan: #00a8c9;
  --cyan-dark: #087a9a;
  --cyan-soft: #e8faff;
  --blue: #1377c9;
  --lime: #a8c900;
  --ink: #173446;
  --muted: #607789;
  --line: #d7e8ee;
  --bg: #f3fbfd;
  --surface: #fff;
  --success: #16794b;
  --danger: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(180deg,#f7fdff 0,#f2fafc 100%); color: var(--ink); font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans JP",sans-serif; line-height: 1.55; }
a { color: var(--cyan-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 22px; }
.main { padding-top: 30px; padding-bottom: 60px; }

.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.97); border-bottom: 3px solid var(--cyan); box-shadow: 0 4px 18px rgba(25,91,112,.09); backdrop-filter: blur(10px); }
.header-inner { min-height: 76px; display: flex; align-items: center; gap: 22px; position: relative; }
.brand { display: flex; align-items: center; gap: 15px; flex: 0 0 auto; color: var(--ink); font-weight: 800; }
.brand:hover { text-decoration: none; }
.brand img { display: block; width: 146px; height: 49px; object-fit: contain; }
.portal-name { padding-left: 15px; border-left: 1px solid #c8e2e9; white-space: nowrap; font-size: 1.03rem; letter-spacing: .03em; }
.nav { display: flex; align-items: center; justify-content: center; gap: 3px; flex: 1; }
.nav a { padding: 9px 10px; border-radius: 7px; color: #36586a; font-size: .88rem; font-weight: 650; white-space: nowrap; }
.nav a:hover { color: var(--cyan-dark); background: var(--cyan-soft); text-decoration: none; }
.account { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.user-name { color: var(--muted); font-size: .86rem; white-space: nowrap; }
.logout, .mobile-logout { margin: 0; }
.logout button { background: #fff; color: var(--cyan-dark); border: 1px solid #acdce7; padding: 7px 11px; }

.mobile-menu { display: none; margin-left: auto; position: relative; }
.mobile-menu summary { width: 46px; height: 44px; display: grid; align-content: center; justify-items: center; gap: 5px; border: 1px solid #a9dce7; border-radius: 9px; background: var(--cyan-soft); cursor: pointer; list-style: none; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu summary span { width: 23px; height: 2px; border-radius: 2px; background: var(--cyan-dark); transition: transform .18s ease,opacity .18s ease; }
.mobile-menu[open] summary span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu[open] summary span:nth-child(2) { opacity: 0; }
.mobile-menu[open] summary span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mobile-menu-panel { position: absolute; right: 0; top: calc(100% + 12px); width: min(330px,calc(100vw - 26px)); padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 42px rgba(20,65,82,.2); }
.mobile-user { padding: 10px 12px 12px; color: var(--muted); font-size: .88rem; border-bottom: 1px solid var(--line); }
.mobile-menu-panel nav { display: grid; padding: 7px 0; }
.mobile-menu-panel nav a { display: block; padding: 11px 12px; border-radius: 7px; color: var(--ink); font-weight: 650; }
.mobile-menu-panel nav a:hover { background: var(--cyan-soft); color: var(--cyan-dark); text-decoration: none; }
.mobile-logout { padding: 9px 8px 4px; border-top: 1px solid var(--line); }
.mobile-logout button { width: 100%; background: #fff; color: var(--danger); border: 1px solid #f0c2be; }

h1 { font-size: 1.65rem; margin: 0 0 22px; color: #173f54; }
h2 { font-size: 1.18rem; margin: 0 0 14px; color: #1c5066; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-bottom: 20px; box-shadow: 0 4px 16px rgba(26,88,107,.055); }
.grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.grid .card { border-top: 3px solid var(--cyan); }
.metric { font-size: 1.9rem; font-weight: 750; color: var(--cyan-dark); }
.muted { color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.btn, button { display: inline-block; border: 0; border-radius: 8px; padding: 9px 15px; background: #e8f0f3; color: var(--ink); font: inherit; font-weight: 650; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(.98); }
.primary { background: linear-gradient(135deg,var(--cyan),#078eb5); color: #fff; box-shadow: 0 3px 9px rgba(0,142,181,.18); }
.danger { background: var(--danger); color: #fff; }
.outline { background: #fff; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .84rem; color: var(--muted); background: #f3fbfd; }
label { display: block; font-weight: 650; margin-bottom: 5px; }
input, select, textarea { width: 100%; padding: 10px 11px; border: 1px solid #b7ced7; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
input:focus,select:focus,textarea:focus { outline: 3px solid rgba(0,168,201,.16); border-color: var(--cyan); }
textarea { min-height: 110px; }
.field { margin-bottom: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; }
.checks { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px 16px; }
.alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 16px; background: var(--cyan-soft); border: 1px solid #b9e6ef; }
.alert-danger { background: #fff0ef; border-color: #f5c2bd; color: #8a1c14; }
.alert-success { background: #edf9f2; border-color: #b6e0c8; color: #12613d; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 99px; background: #e7f0f3; color: #36586a; font-size: .78rem; }
.badge.synced,.badge.scheduled,.badge.completed { background: #daf3e5; color: #12613d; }
.badge.failed,.badge.calendar_sync_failed,.badge.zoom_sync_failed { background: #fee4e2; color: #8a1c14; }
.badge.pending,.badge.retry,.badge.processing { background: #fff3cd; color: #785b00; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.actions .btn,.actions button { padding: 6px 10px; font-size: .85rem; }
.login { max-width: 440px; margin: 42px auto; border-top: 4px solid var(--cyan); }
.login-brand { display: grid; justify-items: center; gap: 7px; margin: 0 0 20px; color: #17475b; font-weight: 800; letter-spacing: .06em; }
.login-brand img { width: 180px; max-width: 72%; height: 60px; object-fit: contain; }
.login h1 { font-size: 1.35rem; }
.passwordless-actions { display: grid; gap: 10px; margin-bottom: 12px; }
.auth-btn { width: 100%; min-height: 45px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid #b8cbd2; border-radius: 8px; padding: 9px 14px; background: #fff; color: var(--ink); font-weight: 700; text-decoration: none; }
.auth-btn:hover { text-decoration: none; background: #f7fbfc; }
.auth-btn:disabled { opacity: .6; cursor: wait; }
.passkey-btn { border-color: var(--cyan); color: var(--cyan-dark); background: var(--cyan-soft); }
.apple-btn { background: #111; border-color: #111; color: #fff; }
.apple-btn:hover { background: #292929; color: #fff; }
.provider-mark { width: 22px; text-align: center; }
.google-mark { color: #4285f4; font-size: 1.15rem; font-weight: 900; }
.apple-mark { font-size: 1.25rem; line-height: 1; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 17px 0 13px; color: var(--muted); font-size: .82rem; }
.auth-divider::before,.auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.login-submit { width: 100%; }
.login-help { margin: 16px 0 0; color: var(--muted); font-size: .78rem; }
.auth-message { min-height: 0; margin-top: 8px; font-size: .86rem; }
.auth-message:not(:empty) { padding: 9px 11px; border-radius: 7px; }
.auth-message.error { color: #8a1c14; background: #fff0ef; }
.auth-message.success { color: #12613d; background: #edf9f2; }
.passkey-add-action { display: flex; align-items: flex-end; }
.passkey-add-action button { min-height: 43px; }
.identity-list { display: grid; margin-bottom: 18px; }
.identity-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.identity-row:first-child { padding-top: 0; }
.identity-row form { margin: 0; }
.setup-heading { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.setup-heading img { width: 180px; height: 60px; object-fit: contain; }
.setup-heading h1,.setup-heading p { margin-bottom: 3px; }
.definition { display: grid; grid-template-columns: 180px 1fr; }
.definition dt,.definition dd { padding: 9px; margin: 0; border-bottom: 1px solid var(--line); }
.definition dt { color: var(--muted); }
.notice { border-left: 4px solid var(--lime); padding: 12px 15px; background: #fbfdeb; margin-bottom: 18px; }
.env-editor { min-height: 560px; resize: vertical; white-space: pre; overflow: auto; tab-size: 2; font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace; font-size: .86rem; line-height: 1.55; }
.confirm-dialog { width: min(620px,calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); box-shadow: 0 22px 60px rgba(16,52,67,.3); }
.confirm-dialog::backdrop { background: rgba(13,42,55,.5); backdrop-filter: blur(2px); }
.dialog-body { padding: 24px; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.changed-keys { max-height: 220px; overflow: auto; padding: 12px 15px; border-radius: 8px; background: var(--cyan-soft); }
.changed-keys ul { margin: 7px 0 0; padding-left: 22px; columns: 2; }
.job-error { max-width: 280px; max-height: 4.7em; overflow: auto; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .desktop-nav,.desktop-account { display: none; }
  .mobile-menu { display: block; }
  .header-inner { min-height: 72px; }
}
@media (max-width: 800px) {
  .wrap { padding: 0 14px; }
  .main { padding-top: 22px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .definition { grid-template-columns: 1fr; }
  .definition dt { padding-bottom: 0; border: 0; }
  .definition dd { padding-top: 2px; }
  .checks { grid-template-columns: 1fr; }
 .brand img { width: 125px; height: 42px; }
 .portal-name { font-size: .92rem; padding-left: 12px; }
 .setup-heading img { width: 135px; height: 46px; }
 .login { margin: 24px auto; }
 .login-brand img { width: 145px; height: 48px; }
}
@media (max-width: 480px) {
  .header-inner { min-height: 66px; gap: 8px; }
  .brand { gap: 8px; min-width: 0; }
 .brand img { width: 88px; height: 30px; }
 .portal-name { font-size: .78rem; padding-left: 8px; white-space: normal; line-height: 1.3; }
 .mobile-menu summary { width: 42px; height: 40px; }
 .grid { grid-template-columns: 1fr; }
 .card { padding: 17px; }
 h1 { font-size: 1.4rem; }
 .setup-heading { align-items: flex-start; gap: 10px; }
 .setup-heading img { width: 100px; height: 38px; }
 .login { margin: 10px auto; padding: 17px; }
 .login-brand { gap: 4px; margin-bottom: 15px; }
 .login-brand img { width: 112px; max-width: 56%; height: 38px; }
 .login-brand div { font-size: .86rem; }
 .env-editor { min-height: 430px; font-size: .78rem; }
 .changed-keys ul { columns: 1; }
}
