:root {
  --bg-canvas: #F4F6F8;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F9FAFB;
  --ink-primary: #101828;
  --ink-secondary: #475467;
  --ink-muted: #667085;
  --border-subtle: #D0D5DD;
  --border-light: #EAECF0;
  --accent-cobalt: #175CD3;
  --accent-cobalt-hover: #1849A9;
  --accent-cobalt-bg: #EFF8FF;
  --status-ok: #067647;
  --status-ok-bg: #ECFDF3;
  --status-ok-border: #ABEFC6;
  --status-warn: #B54708;
  --status-warn-bg: #FFFAEB;
  --status-warn-border: #FEDF89;
  --status-danger: #B42318;
  --status-danger-bg: #FEF3F2;
  --status-danger-border: #FECDCA;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-cobalt);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  color: var(--ink-primary);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent-cobalt);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.container-narrow {
  max-width: 540px;
  margin: 56px auto;
  padding: 0 16px;
}

.container-wide {
  max-width: 1680px;
  width: 100%;
  margin: 20px auto;
  padding: 0 20px 48px;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--ink-secondary);
  font-size: 13px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--ink-primary);
  font-size: 13px;
}

.form-hint {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 4px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-primary);
  background: #fff;
  transition: border-color 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-cobalt);
  box-shadow: 0 0 0 3px rgba(23, 92, 211, 0.12);
}

.textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
}

.input-mono {
  font-family: var(--font-mono);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--ink-primary);
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--bg-subtle);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-cobalt);
  border-color: var(--accent-cobalt);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-cobalt-hover);
  border-color: var(--accent-cobalt-hover);
}

.btn-danger {
  background: var(--status-danger-bg);
  border-color: var(--status-danger-border);
  color: var(--status-danger);
}
.btn-danger:hover:not(:disabled) {
  background: #FEE4E2;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

/* Foreground TOTP Card (The Focal Element) */
.totp-card {
  margin-top: 20px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-surface);
  padding: 22px 24px;
}

.totp-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.totp-service {
  font-size: 13px;
  color: var(--ink-secondary);
  font-weight: 500;
}

.totp-username {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-primary);
  margin-top: 2px;
  word-break: break-all;
}

.totp-display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.totp-digits {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink-primary);
  line-height: 1.1;
  user-select: all;
}

.totp-digits.expiring {
  color: var(--status-warn);
}

.totp-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.countdown-ring-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.countdown-svg {
  transform: rotate(-90deg);
  width: 44px;
  height: 44px;
}

.countdown-track {
  fill: none;
  stroke: var(--border-light);
  stroke-width: 4;
}

.countdown-bar {
  fill: none;
  stroke: var(--accent-cobalt);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s linear, stroke 0.2s;
}

.countdown-bar.expiring {
  stroke: var(--status-warn);
}

.countdown-num {
  position: absolute;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
}

/* Tabs & Metric Strip */
.tabs-nav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover {
  color: var(--ink-primary);
}
.tab-btn.active {
  color: var(--accent-cobalt);
  border-bottom-color: var(--accent-cobalt);
  font-weight: 600;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 18px;
}

.metric-label {
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.metric-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

/* Action & Filter Bars */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Data Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-surface);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th {
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-weight: 600;
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

table.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

table.data-table th:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--bg-subtle);
  box-shadow: -2px 0 6px rgba(16, 24, 40, 0.05);
}

table.data-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--bg-surface);
  box-shadow: -2px 0 6px rgba(16, 24, 40, 0.05);
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover td {
  background: #F8FAFC;
}

table.data-table tr:hover td:last-child {
  background: #F8FAFC;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok);
  border-color: var(--status-ok-border);
}

.badge-warn {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border-color: var(--status-warn-border);
}

.badge-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border-color: var(--status-danger-border);
}

.badge-neutral {
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  border-color: var(--border-subtle);
}

.badge-info {
  background: var(--accent-cobalt-bg);
  color: var(--accent-cobalt);
  border-color: #B2DDFF;
}

/* Live Job Console */
.job-box {
  background: #0F172A;
  color: #E2E8F0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

.job-logs {
  max-height: 220px;
  overflow-y: auto;
  background: #020617;
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Alerts & Modals */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border-color: var(--status-danger-border);
}
.alert-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok);
  border-color: var(--status-ok-border);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  max-width: 640px;
  width: 100%;
  padding: 22px 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .totp-digits {
    font-size: 32px;
  }
}

.hidden {
  display: none !important;
}
