/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f2f4;
  --white:     #ffffff;
  --border:    #c8ccd0;
  --border-lt: #e0e4e8;
  --text:      #3a3a3a;
  --muted:     #767676;
  --link:      #0055b3;
  --blue:      #366393;
  --green:     #2d7a32;
  --red:       #b0291e;
  --orange:    #946200;
  --teal:      #006d7a;
  --purple:    #5a2d91;
}

html, body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  min-height: 100%;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: 13px; }

/* ── Site Header ─────────────────────────────────────────────────────────── */
.header-bg {
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.site-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: bold;
  color: var(--blue);
  letter-spacing: -.3px;
}
.site-logo-icon { font-size: 26px; }
.site-user { font-size: 12px; color: var(--muted); }
.site-user strong { color: var(--text); }
.site-user a { color: var(--link); }
.site-user a:hover { text-decoration: underline; }

/* ── Navigation ──────────────────────────────────────────────────────────── */
.site-nav {
  background: var(--white);
  border-bottom: 2px solid var(--border);
}
.nav-tabs {
  display: flex;
  padding: 0 20px;
  max-width: 1120px;
  margin: 0 auto;
}
.nav-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -2px;
  transition: color .12s;
}
.nav-tab:hover  { color: var(--blue); background: #f5f7f9; }
.nav-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }

/* ── Page wrapper ────────────────────────────────────────────────────────── */
.page-wrap { max-width: 1120px; margin: 0 auto; padding: 22px 20px 40px; }

/* ── Pane switching ──────────────────────────────────────────────────────── */
.pane { display: none; }
.pane.active { display: block; }

/* ── Pane header row ─────────────────────────────────────────────────────── */
.pane-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pane-hd h2 { font-size: 18px; font-weight: bold; color: var(--text); }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.panel { background: var(--white); border: 1px solid var(--border); margin-bottom: 16px; }
.panel-head {
  background: #f5f7f8;
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title { font-size: 13px; font-weight: bold; color: var(--text); }
.panel-body  { padding: 16px; }

/* ── Stat strip ──────────────────────────────────────────────────────────── */
.stat-strip {
  display: flex;
  background: var(--white);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}
.stat-cell {
  flex: 1;
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.stat-cell:last-child { border-right: none; }
.stat-num { font-size: 30px; font-weight: bold; color: var(--blue); line-height: 1; }
.stat-lbl { font-size: 11px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .05em; }

/* ── Two-col layout ──────────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }

/* ── Table ───────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #edf0f2;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 7px 10px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}
thead th:first-child { border-left: none; }
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-lt);
  vertical-align: middle;
  font-size: 13px;
}
tbody tr:hover td { background: #f5f8fb; }
tbody tr:last-child td { border-bottom: none; }
.empty-td { text-align: center; color: var(--muted); padding: 28px !important; font-style: italic; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f0f2f4;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background .1s;
  line-height: 1.4;
}
.btn:hover { background: #e2e5e9; text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; border-color: #2a4f7a; }
.btn-primary:hover { background: #2a4f7a; }
.btn-success { background: var(--green); color: #fff; border-color: #1f5424; }
.btn-success:hover { background: #1f5424; }
.btn-danger  { background: var(--red); color: #fff; border-color: #8a1f16; }
.btn-danger:hover  { background: #8a1f16; }
.btn-sm  { padding: 4px 9px; font-size: 11px; }
.btn-lg  { padding: 9px 18px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; margin-top: 6px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.fld { margin-bottom: 12px; }
.lbl { display: block; font-size: 11px; font-weight: bold; color: #555; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.inp {
  width: 100%;
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 2px;
  background: var(--white);
  color: var(--text);
}
.inp:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(54,99,147,.15); }
.inp::placeholder { color: #b0b4b8; }
.inp-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.inp-row  { display: flex; gap: 8px; }

/* ── Mini select ─────────────────────────────────────────────────────────── */
.mini-sel {
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 3px 6px;
  background: var(--white);
  cursor: pointer;
  color: var(--text);
}

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #ddeeff;
  border: 1px solid #b8daff;
  color: #004085;
  border-radius: 2px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}
.tag button { background: none; border: none; cursor: pointer; color: #004085; font-size: 11px; line-height: 1; padding: 0 1px; }
.tag button:hover { color: var(--red); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: bold;
  border: 1px solid transparent;
}
.b-green  { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.b-blue   { background: #cce5ff; color: #004085; border-color: #b8daff; }
.b-teal   { background: #d1ecf1; color: #0c5460; border-color: #bee5eb; }
.b-orange { background: #fff3cd; color: #6d4c00; border-color: #fce484; }
.b-red    { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.b-gray   { background: #e9ecef; color: #495057; border-color: #dee2e6; }
.b-purple { background: #ede0ff; color: #4a1a80; border-color: #d4b8ff; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200; display: flex; align-items: center; justify-content: center; }
.overlay.hidden { display: none; }
.modal {
  background: var(--white);
  border: 1px solid #999;
  width: 500px;
  max-width: 95vw;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.modal-hd {
  background: var(--blue);
  color: var(--white);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: bold;
}
.modal-hd button { background: none; border: none; color: rgba(255,255,255,.8); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }
.modal-hd button:hover { color: #fff; }
.modal-body { padding: 18px; }
.divider { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 11px; font-weight: bold; text-transform: uppercase; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Code value ──────────────────────────────────────────────────────────── */
.code-val {
  font-family: 'Courier New', monospace;
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 2px;
  color: var(--blue);
  cursor: pointer;
}
.code-val:hover { text-decoration: underline; }

/* ── Row-item (sidebar lists) ────────────────────────────────────────────── */
.row-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border-lt); font-size: 12px; }
.row-item:last-child { border-bottom: none; }
.row-info { flex: 1; min-width: 0; }
.row-name { font-weight: bold; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub  { font-size: 11px; color: var(--muted); }
.row-time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ── Del button ──────────────────────────────────────────────────────────── */
.del-btn { background: none; border: none; cursor: pointer; color: #bbb; font-size: 13px; padding: 3px 6px; border-radius: 2px; }
.del-btn:hover { color: var(--red); background: #fdf0f0; }

/* ── Provider buttons (OAuth) ────────────────────────────────────────────── */
.prov-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 3px; background: var(--white); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); margin-bottom: 8px; }
.prov-btn:hover { background: var(--bg); text-decoration: none; }

/* ── Status dot ──────────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2d7a32;
  box-shadow: 0 0 0 0 rgba(45,122,50,.6);
  animation: pulse-dot 1.6s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(45,122,50,.6); }
  60%  { box-shadow: 0 0 0 6px rgba(45,122,50,0); }
  100% { box-shadow: 0 0 0 0 rgba(45,122,50,0); }
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast { position: fixed; bottom: 20px; right: 20px; background: #333; color: #fff; padding: 9px 16px; border-radius: 3px; font-size: 12px; font-weight: bold; opacity: 0; transition: opacity .2s; z-index: 9999; pointer-events: none; }
#toast.show { opacity: 1; }
#toast.ok  { background: var(--green); }
#toast.err { background: var(--red); }

/* ── Copy flash ──────────────────────────────────────────────────────────── */
#copyflash { position: fixed; top: 70px; right: 20px; background: var(--green); color: #fff; padding: 8px 14px; border-radius: 3px; font-size: 12px; font-weight: bold; opacity: 0; transition: opacity .3s; z-index: 9999; pointer-events: none; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer { text-align: center; padding: 14px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 30px; background: var(--white); }

/* ── User portal specific ────────────────────────────────────────────────── */
.up-welcome { padding: 14px 0 18px; }
.up-welcome h2 { font-size: 20px; font-weight: bold; margin-bottom: 4px; }
.up-welcome p  { color: var(--muted); font-size: 13px; }

.code-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); margin-bottom: 20px; }
.code-card { background: var(--white); padding: 16px; }
.code-card-prod { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.code-card-icon { font-size: 22px; }
.code-card-name { font-weight: bold; font-size: 14px; }
.code-card-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.code-big {
  font-family: 'Courier New', monospace;
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 4px;
  color: var(--blue);
  cursor: pointer;
  display: block;
  margin: 6px 0 4px;
}
.code-big:hover { text-decoration: underline; }
.code-time { font-size: 11px; color: var(--muted); }
.no-code { color: var(--muted); font-style: italic; font-size: 13px; }
