:root {
  color-scheme: light;
  --background: #f4f5f7;
  --panel: #ffffff;
  --text: #17181b;
  --muted: #6a6f78;
  --line: #dfe2e7;
  --primary: #5b45d6;
  --primary-hover: #4934bd;
  --success: #16845b;
  --danger: #c43c45;
  --shadow: 0 10px 30px rgba(22, 24, 29, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }

.site-header {
  min-height: 64px;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header form { margin: 0; }
.brand { font-size: 18px; font-weight: 750; text-decoration: none; letter-spacing: -0.02em; }
.container { width: min(1040px, calc(100% - 32px)); margin: 42px auto 80px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(28px, 5vw, 38px); letter-spacing: -0.04em; line-height: 1.1; }
h2 { margin-bottom: 4px; font-size: 19px; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--primary); font-size: 12px; font-weight: 750; letter-spacing: 0.11em; text-transform: uppercase; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.compact-heading { align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.empty-state { padding: 54px 28px; text-align: center; }
.empty-state p { color: var(--muted); }
.link-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.link-card { padding: 22px; }
.card-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.card-heading p { margin: 0; font-size: 13px; }

.badge { padding: 4px 9px; border-radius: 100px; font-size: 12px; font-weight: 700; }
.badge-on { color: #096442; background: #ddf5eb; }
.badge-off { color: #6a6f78; background: #eceef1; }
.connection-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.connection { padding: 13px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.connection + .connection { border-top: 1px solid var(--line); }
.connection div { min-width: 0; display: grid; }
.connection strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-name, .connected { color: var(--muted); font-size: 12px; }
.connected { color: var(--success); }
.attention { color: #9a5b00; font-size: 12px; }
.connection-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.connection-actions form { margin: 0; }
.option-group { margin: 0; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 10px; }
.option-group legend { padding: 0 6px; font-weight: 680; }
.option-group .hint { margin-top: -6px; }

.sync-status { display: flex; gap: 10px; margin: 18px 0; color: var(--muted); }
.sync-status div { display: grid; }
.sync-status strong { color: var(--text); font-size: 13px; }
.sync-status span { font-size: 12px; }
.status-dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #afb4bd; }
.status-success .status-dot { background: var(--success); }
.status-failed .status-dot { background: var(--danger); }
.status-running .status-dot { background: var(--primary); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.sync-progress { width: 100%; height: 6px; margin: 6px 0 4px; appearance: none; border: 0; border-radius: 100px; overflow: hidden; background: #e6e8ec; }
.sync-progress::-webkit-progress-bar { background: #e6e8ec; border-radius: 100px; }
.sync-progress::-webkit-progress-value { background: var(--primary); border-radius: 100px; transition: width 0.4s ease; }
.sync-progress::-moz-progress-bar { background: var(--primary); border-radius: 100px; }
.sync-progress:indeterminate::-webkit-progress-bar { background: repeating-linear-gradient(90deg, #e6e8ec 0 12px, #d3c9ff 12px 24px); }
.sync-progress:indeterminate::-moz-progress-bar { background: repeating-linear-gradient(90deg, #e6e8ec 0 12px, #d3c9ff 12px 24px); }
.card-actions, .form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.button {
  appearance: none;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 680;
  text-decoration: none;
}

.button:hover { border-color: #b8bdc6; }
.button-primary { border-color: var(--primary); background: var(--primary); color: white; }
.button-primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button-danger { border-color: var(--danger); color: var(--danger); }
.button-quiet { min-height: 34px; border-color: transparent; color: var(--muted); }
.button-small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.button:disabled { cursor: not-allowed; opacity: 0.45; }

.notice { margin-bottom: 18px; padding: 12px 14px; border: 1px solid; border-radius: 9px; }
.notice-success { border-color: #a6dfcb; background: #eaf8f3; color: #096442; }
.notice-error { border-color: #efb7bb; background: #fff0f1; color: #9f2730; }
.login-panel, .form-panel { width: min(100%, 570px); margin: 10vh auto 0; padding: 28px; }
.form-panel { margin: 0; }
.stack { display: grid; gap: 20px; }
label { display: grid; gap: 7px; font-weight: 680; }
input, select { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #cbd0d8; border-radius: 8px; background: white; color: var(--text); font: inherit; }
input:focus, select:focus { outline: 3px solid rgba(91, 69, 214, 0.15); border-color: var(--primary); }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 17px; min-height: 17px; }
.danger-zone { width: min(100%, 570px); margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.danger-zone p { color: var(--muted); }

@media (max-width: 760px) {
  .site-header { padding: 0 18px; }
  .container { margin-top: 28px; }
  .page-heading { align-items: start; flex-direction: column; }
  .link-grid { grid-template-columns: 1fr; }
  .login-panel, .form-panel { margin-top: 0; padding: 22px; }
}
