:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-dim: #edf2ee;
  --header: #16221d;
  --header-soft: #1e2f28;
  --accent: #1f9d7c;
  --accent-bright: #2ab992;
  --accent-soft: rgba(31, 157, 124, 0.1);
  --gold: #b08d57;
  --gold-bright: #c8a06e;
  --text: #1e2a26;
  --text-dim: #62726b;
  --text-on-header: #f4f7f5;
  --text-on-header-dim: #9fb0a8;
  --danger: #c1503a;
  --success: #1f9d7c;
  --border: rgba(30, 42, 38, 0.12);
  --border-header: rgba(244, 247, 245, 0.14);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at top left, rgba(31, 157, 124, 0.07), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(176, 141, 87, 0.05), transparent 50%);
  color: var(--text);
  font-family: "Century Gothic", "Jost", -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- */
/* Brand bar                                                           */
/* ---------------------------------------------------------------- */

.brand-bar {
  background: var(--header);
  padding: 16px 24px;
}

.brand-bar-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.brand-bar img {
  height: 78px;
  width: auto;
  display: block;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

h1, h2, h3 {
  font-family: "Century Gothic", "Jost", sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 6px;
  color: var(--text);
}

a { color: inherit; }

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}

/* ---------------------------------------------------------------- */
/* Flash messages                                                     */
/* ---------------------------------------------------------------- */

.flash-stack {
  max-width: 460px;
  margin: 0 auto 24px;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.flash-error { border-color: rgba(193, 80, 58, 0.4); background: rgba(193, 80, 58, 0.08); }
.flash-success { border-color: rgba(31, 157, 124, 0.4); background: rgba(31, 157, 124, 0.08); }

/* ---------------------------------------------------------------- */
/* Auth card (client + admin login)                                   */
/* ---------------------------------------------------------------- */

.auth-shell {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 40px 34px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(30, 42, 38, 0.08);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.auth-card p.subtitle {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0 0 28px;
}

label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field { margin-bottom: 20px; }

input[type=text], input[type=password], input[type=file] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-dim);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  color: var(--text);
}

input[type=text]:focus, input[type=password]:focus {
  outline: 2px solid var(--accent-bright);
  outline-offset: 1px;
}

button, .btn {
  font-family: "Century Gothic", "Jost", sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  border-radius: var(--radius);
  padding: 11px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  justify-content: center;
}
.btn-primary:hover { background: var(--accent-bright); }

.btn-brass { background: var(--gold); color: var(--header); }
.btn-brass:hover { background: var(--gold-bright); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(30, 42, 38, 0.05); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #cf6650; }

.btn-small { padding: 6px 12px; font-size: 0.78rem; }

/* ---------------------------------------------------------------- */
/* Header / nav                                                       */
/* ---------------------------------------------------------------- */

.top-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.top-bar .who { color: var(--text-dim); font-size: 0.9rem; }
.top-bar a.logout {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: var(--radius);
}
.top-bar a.logout:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- */
/* File manifest (ledger-style list)                                  */
/* ---------------------------------------------------------------- */

.panel {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 30px;
  margin-bottom: 28px;
  box-shadow: 0 1px 2px rgba(30, 42, 38, 0.04);
}

.manifest { width: 100%; border-collapse: collapse; }
.manifest th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding: 0 10px 10px;
  font-weight: 600;
}
.manifest td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.94rem;
  vertical-align: middle;
}
.manifest tr:last-child td { border-bottom: none; }
.manifest .fname { font-family: "IBM Plex Mono", monospace; }
.manifest .fmeta { font-family: "IBM Plex Mono", monospace; color: var(--text-dim); font-size: 0.82rem; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
}
.empty-state .eyebrow { color: var(--gold); }

/* ---------------------------------------------------------------- */
/* Admin: client cards                                                 */
/* ---------------------------------------------------------------- */

.client-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: 0 1px 2px rgba(30, 42, 38, 0.04);
}

.client-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.client-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.status-pill {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid;
}
.status-active { color: var(--accent); border-color: var(--accent); }
.status-disabled { color: var(--danger); border-color: var(--danger); }

.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.upload-row { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.upload-row input[type=file] { flex: 1; }

details.danger-zone { margin-top: 16px; }
details.danger-zone summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.danger-zone .confirm-row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.danger-zone input[type=text] { max-width: 220px; }

/* ---------------------------------------------------------------- */
/* Signature element: the access-code ticket stub                     */
/* ---------------------------------------------------------------- */

.ticket {
  background: var(--header);
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 22px;
  position: relative;
}

.ticket::before, .ticket::after {
  content: "";
  width: 18px;
  height: 18px;
  background: var(--bg);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.ticket::before { left: -9px; }
.ticket::after { right: -9px; }

.ticket .stub-meta { flex: 1; min-width: 160px; }
.ticket .stub-meta .eyebrow { margin-bottom: 4px; color: var(--gold-bright); }
.ticket .stub-meta .name { font-family: "Century Gothic", "Jost", sans-serif; font-size: 1.2rem; color: var(--text-on-header); }
.ticket .stub-meta .id { font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; color: var(--text-on-header-dim); }

.ticket .stub-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  background: rgba(176, 141, 87, 0.14);
  padding: 10px 16px;
  border-radius: var(--radius);
  user-select: all;
}

.ticket-note {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: -18px 0 28px;
}

/* ---------------------------------------------------------------- */
/* New client form                                                     */
/* ---------------------------------------------------------------- */

.new-client-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.new-client-form .field { flex: 1; margin-bottom: 0; }

@media (max-width: 640px) {
  .wrap { padding: 28px 16px 60px; }
  .auth-card { padding: 30px 22px 26px; }
  .new-client-form { flex-direction: column; align-items: stretch; }
  .ticket { flex-direction: column; align-items: flex-start; }
  .client-card-head { flex-direction: column; }
  .manifest thead { display: none; }
  .manifest tr { display: block; padding: 10px 0; }
  .manifest td { display: block; border: none; padding: 2px 0; }
}
