/* Customs Support Group admin UI.
   Palette taken from the official CSG brand kit (Official CSG Colours.docx). */

:root {
  --csg-teal: #009bab;
  --csg-teal-dark: #0c6d71;
  --csg-teal-050: #e6efef;
  --csg-teal-100: #cae4e8;
  --csg-teal-200: #b4dadf;
  --csg-blue: #0098c9;
  --csg-blue-050: #d0e6ef;
  --csg-purple: #4e2f7c;
  --csg-purple-100: #cbbfd8;
  --csg-orange: #e77e20;
  --csg-orange-050: #f7e5d2;

  --ink: #1c1f23;
  --ink-muted: #5c6672;
  --ink-faint: #8b95a1;
  --line: #dfe4ea;
  --line-soft: #eef1f5;
  --surface: #ffffff;
  --canvas: #f5f7f9;

  --ok: #1a7f4b;
  --ok-bg: #e4f4ec;
  --warn: #9a5b00;
  --warn-bg: #fdf0dd;
  --bad: #b3261e;
  --bad-bg: #fbe6e5;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(28, 31, 35, 0.06), 0 4px 12px rgba(28, 31, 35, 0.04);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

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

a { color: var(--csg-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout -------------------------------------------------------------- */

.topbar {
  background: var(--surface);
  border-bottom: 3px solid var(--csg-teal);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 62px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 30px; width: auto; display: block; }
.brand:hover { text-decoration: none; }
.brand-divider { width: 1px; height: 26px; background: var(--line); }
.brand-title { font-weight: 600; color: var(--ink); font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { display: block; font-size: 11px; color: var(--ink-faint); font-weight: 400; letter-spacing: 0.03em; text-transform: uppercase; }

nav.main { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
nav.main a {
  padding: 7px 13px;
  border-radius: var(--radius);
  color: var(--ink-muted);
  font-weight: 500;
}
nav.main a:hover { background: var(--csg-teal-050); color: var(--csg-teal-dark); text-decoration: none; }
nav.main a.active { background: var(--csg-teal); color: #fff; }

.session { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--ink-faint); }

main { max-width: 1360px; margin: 0 auto; padding: 28px 24px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; color: var(--ink); }
.page-head p { margin: 4px 0 0; color: var(--ink-muted); font-size: 13px; }

/* --- Cards & stats ------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-body { padding: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--csg-teal);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}
.stat.blue { border-left-color: var(--csg-blue); }
.stat.purple { border-left-color: var(--csg-purple); }
.stat.orange { border-left-color: var(--csg-orange); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 600; }
.stat-value { font-size: 27px; font-weight: 600; margin-top: 5px; letter-spacing: -0.02em; }
.stat-value.small { font-size: 15px; font-weight: 500; padding-top: 8px; }
.stat-note { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }
.stat-value.attention { color: var(--csg-orange); }

/* --- Tables -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--csg-teal-050);
  color: var(--csg-teal-dark);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-faint); }

/* --- Badges -------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge.regime-CDS { background: var(--csg-teal-100); color: var(--csg-teal-dark); }
.badge.regime-NCTS { background: var(--csg-purple-100); color: var(--csg-purple); }
.badge.regime-INVENTORY { background: var(--csg-orange-050); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.neutral { background: var(--line-soft); color: var(--ink-muted); }
.badge.role-ingest { background: var(--csg-blue-050); color: #04607f; }
.badge.role-read { background: var(--csg-teal-100); color: var(--csg-teal-dark); }
.badge.role-admin { background: var(--csg-purple-100); color: var(--csg-purple); }

/* --- Forms & buttons ----------------------------------------------------- */

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input[type="text"], input[type="password"], input[type="search"],
input[type="email"], select, textarea {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--csg-teal);
  outline-offset: -1px;
  border-color: var(--csg-teal);
}
label { font-size: 12px; font-weight: 600; color: var(--ink-muted); display: block; margin-bottom: 4px; }

.btn {
  display: inline-block;
  padding: 7px 15px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--csg-teal);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.5;
}
.btn:hover { background: var(--csg-teal-dark); text-decoration: none; color: #fff; }
.btn.secondary { background: var(--surface); color: var(--ink-muted); border-color: var(--line); }
.btn.secondary:hover { background: var(--csg-teal-050); color: var(--csg-teal-dark); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #edc9c7; }
.btn.danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12px; }

.checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-muted); }
.checkbox input { margin: 0; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }

/* --- Detail lists -------------------------------------------------------- */

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 26px; }
.detail dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); font-weight: 600; }
.detail dd { margin: 2px 0 0; font-size: 13px; word-break: break-word; }

pre.xml {
  background: #1c2128;
  color: #d8dee9;
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  white-space: pre;
}

.notice {
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--csg-teal-200);
  background: var(--csg-teal-050);
  margin-bottom: 18px;
  font-size: 13px;
}
.notice.warn { border-color: #f0cfa0; background: var(--warn-bg); }
.notice strong { display: block; margin-bottom: 5px; }
.notice code { font-family: var(--mono); background: rgba(255, 255, 255, 0.75); padding: 3px 7px; border-radius: 4px; word-break: break-all; display: inline-block; }

.pager { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--ink-muted); }
.pager .spacer { flex: 1; }

/* --- Sign in ------------------------------------------------------------- */

.login-wrap { max-width: 400px; margin: 9vh auto; padding: 0 20px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 32px; }
.login-logo { display: block; height: 42px; margin: 0 auto 22px; }
.login-card h1 { font-size: 18px; text-align: center; margin-bottom: 6px; }
.login-card p.sub { text-align: center; color: var(--ink-muted); font-size: 13px; margin: 0 0 22px; }
.login-card input { width: 100%; margin-bottom: 14px; font-family: var(--mono); }
.login-card .btn { width: 100%; text-align: center; }
.login-error { background: var(--bad-bg); color: var(--bad); padding: 10px 13px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }

footer.foot { text-align: center; color: var(--ink-faint); font-size: 12px; padding: 26px 20px 40px; }

@media (max-width: 720px) {
  .topbar-inner { min-height: auto; padding: 12px 16px; }
  nav.main { margin-left: 0; width: 100%; }
  main { padding: 20px 16px 48px; }
}

/* --- Sign-in additions --------------------------------------------------- */

.login-card input[type="email"] { font-family: var(--font); }

.code-input {
  text-align: center;
  font-family: var(--mono);
  font-size: 26px !important;
  font-weight: 600;
  letter-spacing: 10px;
  text-indent: 10px; /* offsets the trailing letter-space so digits look centred */
  padding: 12px 8px !important;
}
.code-input::placeholder { color: var(--line); letter-spacing: 10px; }

.login-alt { text-align: center; font-size: 13px; color: var(--ink-muted); margin: 18px 0 0; }
.login-foot { text-align: center; font-size: 12px; color: var(--ink-faint); margin-top: 18px; }
.login-card p.sub strong { color: var(--ink); font-weight: 600; }
