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

:root {
  --blue:     #0078d4;
  --blue-dk:  #005a9e;
  --blue-lt:  #deecf9;
  --bg:       #f3f3f3;
  --surface:  #ffffff;
  --border:   #e1e1e1;
  --text:     #1f1f1f;
  --muted:    #616161;
  --success:  #107c10;
  --warn:     #7a6600;
  --warn-bg:  #fff4ce;
  --error:    #d13438;
  --radius:   4px;
  --font:     'Segoe UI', system-ui, sans-serif;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Views ──────────────────────────────────────────────────────────── */
.view          { display: none; }
.view.active   { display: block; }

/* ── Center card (login + setup) ───────────────────────────────────── */
.center-card {
  max-width: 440px; margin: 80px auto; background: var(--surface);
  border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.12);
  padding: 48px 40px; text-align: center;
}
.logo    { font-size: 26px; font-weight: 700; color: var(--blue); margin-bottom: 8px; }
.logo-sm { font-size: 16px; font-weight: 700; color: var(--blue); }
.tagline { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 32px; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; border: none; cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dk); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--blue-lt); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #0b5e0b; }
.btn-ghost    { background: none; color: var(--muted); border: none; font-size: 13px; }
.btn-ghost:hover { color: var(--text); }
.btn-xs       { padding: 2px 8px; font-size: 11px; }

.btn-ms {
  background: #fff; border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; font-size: 15px; width: 100%; justify-content: center;
  border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.btn-ms:hover { box-shadow: 0 2px 6px rgba(0,0,0,.18); }

/* ── Setup form ──────────────────────────────────────────────────────── */
.setup-form { text-align: left; }
.setup-form label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; }
.provider-pills { display: flex; gap: 8px; }
.pill {
  flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-size: 13px; transition: all .15s;
}
.pill.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint a { color: var(--blue); }

input[type="password"],
input[type="text"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-family: var(--font);
  outline: none; transition: border-color .15s;
}
input[type="password"]:focus,
input[type="text"]:focus { border-color: var(--blue); }

/* ── Confirm screen ─────────────────────────────────────────────────── */
.confirm-box       { text-align: center; }
.confirm-icon      { margin-bottom: 16px; }
.confirm-label     { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.confirm-account   { font-size: 18px; font-weight: 700; color: var(--text); }
.confirm-email     { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.confirm-info      {
  font-size: 13px; color: var(--muted); line-height: 1.6;
  background: #f0f7ff; border-radius: 4px; padding: 12px 14px;
  margin-bottom: 20px; text-align: left;
}

/* ── Header ──────────────────────────────────────────────────────────── */
header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 24px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }
#user-name { font-size: 13px; color: var(--muted); }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: #f0f0f0; color: var(--muted); font-weight: 600;
}
.badge-ai  { background: var(--blue-lt); color: var(--blue-dk); }
.badge-ok  { background: #dff6dd; color: var(--success); }
.badge-warn{ background: #fff4ce; color: #7a6600; cursor: help; }

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; flex-wrap: wrap;
}
.sep         { flex: 1; }
.sel-count   { font-size: 13px; color: var(--muted); }

/* ── Table ───────────────────────────────────────────────────────────── */
.table-wrap {
  margin: 0 24px; background: var(--surface);
  border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.08); overflow: hidden;
}
table         { width: 100%; border-collapse: collapse; font-size: 13px; }
thead         { background: #f0f0f0; }
th            { padding: 9px 12px; text-align: left; font-size: 11px; font-weight: 700;
                color: var(--muted); text-transform: uppercase; letter-spacing: .3px;
                border-bottom: 1px solid var(--border); }
td            { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td   { background: var(--blue-lt); }

.app-name   { font-weight: 600; }
.app-id     { font-size: 11px; color: var(--muted); margin-top: 2px; }
.desc-cell  { max-width: 260px; color: var(--muted); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desc-cell.has-gen { color: var(--text); font-style: normal; }
.empty      { text-align: center; padding: 40px; color: var(--muted); }

/* Editable generated description — admin can correct before writing */
.gen-edit {
  width: 100%; min-width: 200px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font); font-size: 13px; color: var(--text);
  background: var(--surface);
}
.gen-edit:focus { outline: none; border-color: var(--blue); }
.gen-edit.gen-flagged { border-color: var(--warn); background: #fff8e6; }

/* ── Log panel ───────────────────────────────────────────────────────── */
.log-panel {
  margin: 16px 24px 24px; background: #1e1e1e; border-radius: 6px; overflow: hidden;
}
.log-header {
  background: #2d2d2d; padding: 8px 14px; font-size: 12px; font-weight: 600;
  color: #9e9e9e; display: flex; align-items: center; justify-content: space-between;
}
#log-output {
  padding: 10px 14px; height: 160px; overflow-y: auto;
  font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 12px;
}
.log-entry        { margin-bottom: 3px; line-height: 1.5; }
.log-entry .ts    { color: #555; margin-right: 8px; }
.log-entry.info   { color: #9cdcfe; }
.log-entry.success{ color: #4ec9b0; }
.log-entry.warning{ color: #ce9178; }
.log-entry.error  { color: #f48771; }
