:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --fg: #1c1e21;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f25;
    --fg: #e7e9ee;
    --muted: #9aa1ad;
    --line: #2c313a;
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

header, main { max-width: 62rem; margin: 0 auto; }
header { margin-bottom: 1.5rem; }
h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
h2 { margin: 0 0 1rem; font-size: 1.05rem; }
h3 { margin: 1.5rem 0 0.6rem; font-size: 0.85rem; text-transform: uppercase;
     letter-spacing: 0.06em; color: var(--muted); }
.sub { margin: 0.25rem 0 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85em; font-weight: normal; text-transform: none; letter-spacing: 0; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* dropzone */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 3rem 1rem;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dz-title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.dz-sub { margin: .4rem 0 0; color: var(--muted); }
.dz-hint { margin: 1rem 0 0; font-size: .85rem; color: var(--muted); }

/* buttons */
button, .button {
  font: inherit;
  padding: .55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--accent-dark); }
button.secondary {
  background: transparent; color: var(--fg); border-color: var(--line);
}
button.secondary:hover { background: var(--bg); }
button.link {
  background: none; border: none; color: var(--accent);
  padding: 0; text-decoration: underline; cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: .6rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* form */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .8rem;
}
label { display: block; font-size: .82rem; color: var(--muted); }
select, input[type=text], input[type=password] {
  display: block; width: 100%; margin-top: .25rem;
  font: inherit; color: var(--fg);
  padding: .45rem .5rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg);
}
.checks { display: flex; flex-wrap: wrap; gap: 1rem; }
.checks label, .logics label {
  display: flex; align-items: baseline; gap: .4rem;
  font-size: .9rem; color: var(--fg);
}
.logics { display: flex; flex-direction: column; gap: .5rem; }
.logics .desc { color: var(--muted); font-size: .82rem; }

/* progress */
.bar {
  height: 8px; background: var(--line);
  border-radius: 99px; overflow: hidden; margin: .5rem 0;
}
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.bar.indeterminate .bar-fill { width: 35%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.status { color: var(--muted); font-size: .9rem; margin: .5rem 0 1rem; }
.file-line { margin: 0 0 .75rem; font-weight: 500; }

/* preview */
.table-scroll {
  overflow: auto; max-height: 24rem;
  border: 1px solid var(--line); border-radius: 8px;
}
table { border-collapse: collapse; font-size: .82rem; width: max-content; min-width: 100%; }
th, td {
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: .35rem .55rem; text-align: left; vertical-align: top;
  max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card); font-weight: 600;
}
/* Two header rows: only the names stay pinned, the keys scroll away under
   them -- pinning both would need a hard-coded row height to stack them. */
.key-row th {
  position: static; z-index: 0;
  background: var(--bg); font-weight: 400; font-style: italic; color: var(--muted);
}
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--fg) 3%, transparent); }

/* summary / notes / report */
.summary, .report { font-size: .87rem; margin-top: 1rem; }
.summary code, .report code {
  background: var(--bg); padding: .05rem .3rem; border-radius: 4px;
  border: 1px solid var(--line); font-size: .95em;
}
.summary span + span::before { content: " · "; color: var(--muted); }
.notes { margin-top: .5rem; font-size: .85rem; color: var(--muted); }
.notes div::before { content: "→ "; }
.report dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; margin: 0; }
.report dt { color: var(--muted); }
.report .warn { color: var(--warn); }
.report .note { color: var(--muted); }

.error {
  background: color-mix(in srgb, var(--err) 12%, transparent);
  border: 1px solid var(--err); color: var(--err);
  padding: .75rem 1rem; border-radius: 8px;
}

/* -------------------------------------------------------- column selection */

.col-toolbar {
  display: flex; align-items: center; gap: .5rem;
  flex-wrap: wrap; margin-bottom: .75rem;
}
.col-toolbar .spacer { flex: 1 1 .5rem; }
.col-save { display: flex; gap: .5rem; flex: 1 1 18rem; min-width: 14rem; }
.col-toolbar input[type=text] { flex: 1; min-width: 7rem; width: auto; margin-top: 0; }
.col-toolbar select { width: auto; min-width: 9rem; max-width: 14rem; margin-top: 0; }
.inline-field {
  display: flex; align-items: center; gap: .4rem;
  font-size: .82rem; color: var(--muted);
}
button.small-btn { padding: .35rem .7rem; font-size: .82rem; }

/* two panes: chosen columns left, the rest right */
.col-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 46rem) { .col-panes { grid-template-columns: 1fr; } }

.col-pane { display: flex; flex-direction: column; min-width: 0; }
.col-pane-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .5rem; padding: 0 .2rem .35rem;
}
.col-pane-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600;
}

.column-list {
  list-style: none; margin: 0; padding: 0;
  height: 22rem; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
}
.column-list.drop-into { border-color: var(--accent); }

.column-list li {
  display: flex; align-items: center; gap: .45rem;
  padding: .3rem .55rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.column-list li:last-child { border-bottom: none; }
.column-list li:hover:not(.locked):not(.col-placeholder) {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.column-list li.dragging { opacity: .4; }
.column-list li.drop-target { border-top: 2px solid var(--accent); }
.column-list li.locked { cursor: default; opacity: .5; }

.col-handle { color: var(--muted); font-size: .9rem; cursor: grab; }
.col-index {
  min-width: 1.7rem; font-size: .75rem; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: right;
}
.col-name {
  flex: 1; font-size: .85rem; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.col-empty {
  font-size: .7rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px;
  padding: 0 .4rem; white-space: nowrap;
}
.col-move { color: var(--muted); font-size: .8rem; opacity: 0; }
.column-list li:hover .col-move { opacity: 1; }
.col-placeholder {
  color: var(--muted); font-size: .82rem; font-style: italic;
  cursor: default; justify-content: center; padding: 1rem;
}

/* Confirmation of the last layout action, next to the hint that explains them. */
.profile-status { color: var(--ok); }

.warn-box {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid var(--warn); color: var(--warn);
  padding: .6rem .8rem; border-radius: 8px;
  font-size: .85rem; margin: 0 0 .75rem;
}

/* ---------------------------------------------------------- admin console */

.center { text-align: center; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.section-head h2 { margin: 0; }
.actions.inline { margin-top: 0; }

.new-link {
  margin-top: 1rem; padding: .9rem 1rem;
  border: 1px solid var(--warn); border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
.warn-line { margin: 0 0 .6rem; font-size: .87rem; color: var(--warn); }
.copy-row { display: flex; gap: .5rem; }
.copy-row input {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; margin-top: 0;
}

button.danger { background: var(--err); }
button.danger:hover { filter: brightness(.9); }
.row-actions { white-space: nowrap; }
.row-actions button { padding: .25rem .6rem; font-size: .78rem; margin-right: .35rem; }

.status-active   { color: var(--ok); font-weight: 600; }
.status-expired  { color: var(--muted); }
.status-revoked  { color: var(--err); }

#links-table td, #audit-table td { white-space: nowrap; }
#audit-table td:last-child { max-width: 20rem; overflow: hidden; text-overflow: ellipsis; }

form label + .actions { margin-top: 1rem; }
#login label { max-width: 22rem; }
