/* === Reset & base === */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #222;
  background: #fafafa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Topbar === */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: #222;
}
.brand:hover { color: #d97706; }
.logo { width: 36px; height: 36px; object-fit: contain; }
.brand-text { font-weight: 600; font-size: 17px; }
.usermenu {
  display: flex; align-items: center; gap: 16px;
  font-size: 14px;
}
.usermenu a { color: #666; text-decoration: none; }
.usermenu a:hover { color: #d97706; }
.user-email { color: #999; font-size: 13px; }

/* === Layout === */
.container {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}
.footer {
  background: #fff;
  border-top: 1px solid #e5e5e5;
  padding: 16px 24px;
  text-align: center;
  font-size: 13px;
  color: #999;
}
.footer a { color: #999; text-decoration: none; }

/* === Cards === */
.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card.centered { max-width: 560px; margin: 0 auto; }
.card.narrow { max-width: 420px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.card-header h1 { margin: 0; }
h1 { font-size: 22px; margin: 0 0 16px; }
.lead { color: #666; margin: 0 0 24px; }

/* === Forms === */
form label {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
}
form input[type="email"],
form input[type="password"],
form input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  font-size: 15px;
  background: #fff;
}
form input:focus { outline: none; border-color: #d97706; box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }
form input[disabled] { background: #f5f5f5; color: #888; }
.checkbox { display: flex; align-items: center; gap: 8px; margin-top: 16px; cursor: pointer; }
.checkbox input { width: auto; }
.checkbox span em { color: #999; font-style: normal; font-size: 13px; }
.help-text { font-size: 13px; color: #999; margin: 6px 0 0; }

/* === Buttons === */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  margin-top: 20px;
}
.btn-primary { background: #d97706; color: #fff; }
.btn-primary:hover { background: #b45309; }
.btn-secondary { background: #f5f5f5; color: #333; border: 1px solid #d4d4d4; }
.btn-secondary:hover { background: #e5e5e5; }
.btn-danger { background: #fff; color: #dc2626; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-row { display: flex; gap: 12px; justify-content: flex-end; margin-top: 28px; }
.actions-form { margin-top: 24px; }
.link-btn { background: none; border: none; color: #666; cursor: pointer; padding: 0; font: inherit; }
.link-btn:hover { color: #d97706; text-decoration: underline; }
.link-danger { color: #dc2626; }
.link-danger:hover { color: #991b1b; }
.inline-form { display: inline; margin: 0; }

/* === Alerts === */
.alert { padding: 12px 16px; border-radius: 4px; margin-bottom: 20px; font-size: 14px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-revoked { background: #fef2f2; border-left: 3px solid #dc2626; color: #7f1d1d; margin-top: 12px; }

/* === Scope box === */
.scope-box { background: #fafafa; border: 1px solid #e5e5e5; border-radius: 6px; padding: 16px 20px; margin: 24px 0; }
.scope-title { margin: 0 0 8px; font-weight: 500; }
.scope-list { margin: 0; padding-left: 20px; font-size: 14px; }
.scope-list li { margin: 4px 0; }
.scope-list code { background: #fff3e0; color: #d97706; padding: 1px 6px; border-radius: 3px; font-size: 13px; }

/* === Devices === */
.device { border: 1px solid #e5e5e5; border-radius: 6px; padding: 16px; margin-bottom: 12px; }
.device.active { background: #fff; }
.device.revoked { background: #fafafa; opacity: 0.85; }
.device-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.device-meta { font-size: 13px; color: #666; line-height: 1.7; }
.device-meta .meta-label { color: #999; }
.device-meta code { background: #f5f5f5; padding: 1px 4px; border-radius: 2px; font-size: 12px; }

/* === Badges === */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; background: #f5f5f5; color: #666; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* === Tables === */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid #e5e5e5; color: #666; font-weight: 500; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.data-table tr:hover { background: #fafafa; }
.actions-cell { display: flex; gap: 12px; align-items: center; }
.actions-cell a { color: #d97706; text-decoration: none; font-size: 13px; }
.actions-cell a:hover { text-decoration: underline; }

.empty { color: #999; text-align: center; padding: 24px; font-style: italic; }
