/* Pipelet Roaming — Momentum-aligned operator UI */

/* Self-hosted serif font — no external requests */
@font-face { font-family:'Source Serif 4'; font-style:italic; font-weight:400; font-display:swap; src:url('/static/fonts/source-serif-4-400-italic.ttf') format('truetype'); }
@font-face { font-family:'Source Serif 4'; font-style:italic; font-weight:700; font-display:swap; src:url('/static/fonts/source-serif-4-700-italic.ttf') format('truetype'); }
@font-face { font-family:'Source Serif 4'; font-style:normal; font-weight:300; font-display:swap; src:url('/static/fonts/source-serif-4-300.ttf') format('truetype'); }
@font-face { font-family:'Source Serif 4'; font-style:normal; font-weight:400; font-display:swap; src:url('/static/fonts/source-serif-4-400.ttf') format('truetype'); }
@font-face { font-family:'Source Serif 4'; font-style:normal; font-weight:500; font-display:swap; src:url('/static/fonts/source-serif-4-500.ttf') format('truetype'); }
@font-face { font-family:'Source Serif 4'; font-style:normal; font-weight:700; font-display:swap; src:url('/static/fonts/source-serif-4-700.ttf') format('truetype'); }


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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, #f5efe4 0%, #ffffff 100%);
  background-attachment: fixed;
  color: #181D27;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #c49a6c, #1170cf 50%, #c49a6c);
  z-index: 10;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(160%) blur(10px);
  position: sticky; top: 0; z-index: 5;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: 'GT Alpina', 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-size: 15px; font-weight: 500; letter-spacing: -0.01em;
  color: #181D27;
}

.auth-hint { font-size: 12px; color: #A4A7AE; cursor: pointer; }
.auth-hint:hover { color: #1170cf; }

.tabs {
  display: flex;
  gap: 4px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 32px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  background: transparent;
  color: #535862;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}
.tab:hover { color: #1170cf; }
.tab.active { color: #1170cf; border-bottom-color: #1170cf; font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-head select,
.section-head input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #D5D7DA;
  border-radius: 6px;
  background: #fff;
  margin-right: 6px;
  font-family: inherit;
}

.content {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 32px;
}

.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}

h2 {
  font-family: 'GT Alpina', 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-size: 22px; font-weight: 500; letter-spacing: -0.3px;
}

h3 {
  font-family: 'GT Alpina', 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-size: 20px; font-weight: 500; margin-bottom: 18px;
}

h4 {
  font-size: 13px; font-weight: 600; color: #535862;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 16px 0 8px;
}

.muted { color: #535862; font-size: 14px; line-height: 1.5; }

button {
  padding: 8px 16px; font-size: 14px; font-weight: 600;
  border-radius: 9999px; border: 1px solid transparent;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
button.primary { background: #1170cf; color: #fff; }
button.primary:hover { background: #0353a8; }
button.ghost { background: #fff; color: #181D27; border-color: #D5D7DA; }
button.ghost:hover { border-color: #1170cf; color: #1170cf; }
button.danger { background: #fff; color: #ab0a15; border-color: #FECDCA; }
button.danger:hover { background: #ffe8ea; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover { border-color: rgba(17, 112, 207, 0.4); box-shadow: 0 4px 12px rgba(0,0,0,0.04); }

.card-header {
  display: flex; justify-content: space-between; align-items: start; gap: 10px;
}
.card-title { font-size: 15px; font-weight: 600; color: #181D27; }
.card-meta { font-size: 12px; color: #A4A7AE; font-family: 'JetBrains Mono', monospace; }
.card-id { color: #1170cf; font-weight: 700; }

.badge {
  display: inline-block; padding: 2px 10px;
  border-radius: 6px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge.active     { background: #cef5eb; color: #185e46; }
.badge.pending    { background: #f5efe4; color: #6b4f2a; }
.badge.registering { background: #fff4d6; color: #8a5a00; }
.badge.none       { background: #eef1f4; color: #4b5563; }
.badge.suspended  { background: #ffe8ea; color: #ab0a15; }

.version-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.version-chip {
  padding: 2px 8px; border-radius: 4px;
  background: #eef4fd; color: #1170cf;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 600;
}

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(24, 29, 39, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 32px; z-index: 100;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: 16px;
  max-width: 640px; width: 100%;
  max-height: 90vh; overflow: auto;
  padding: 28px 32px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-card.large { max-width: 900px; }
.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #414651; font-weight: 500; }
.modal-card input, .modal-card select, .modal-card textarea {
  padding: 8px 12px; font-size: 14px;
  border: 1px solid #D5D7DA; border-radius: 8px;
  background: #fff; color: #181D27; font-family: inherit;
}
.modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus {
  outline: none; border-color: #1170cf;
  box-shadow: 0 0 0 3px rgba(17,112,207,0.12);
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }

.token-box {
  background: #f8f9fa;
  border: 1px solid #D5D7DA;
  border-radius: 8px;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: #181D27;
  margin: 16px 0;
}

.detail-section { margin: 16px 0; }
.detail-kv {
  display: grid; grid-template-columns: 180px 1fr; gap: 8px;
  font-size: 13px; margin: 4px 0;
}
.detail-kv .k { color: #535862; font-weight: 500; }
.detail-kv .v { color: #181D27; font-family: 'JetBrains Mono', monospace; }

.cred-row {
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.cred-row .left { display: flex; flex-direction: column; gap: 4px; }
.cred-row .actions { display: flex; gap: 6px; }
.cred-row button { padding: 4px 10px; font-size: 12px; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 18px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 200;
  max-width: 420px;
}
.toast.ok  { background: #cef5eb; color: #185e46; border: 1px solid #A6F4C5; }
.toast.err { background: #ffe8ea; color: #ab0a15; border: 1px solid #FECDCA; }

/* Data-table for outbox/cdrs/dead tabs */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}
.data-table th {
  background: #f8f9fa;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #535862;
  letter-spacing: 0.04em;
}
.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table td.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #535862; }
.data-table td.r { text-align: right; }
.data-table td.c { text-align: center; }
.data-table .state-pill {
  display: inline-block; padding: 2px 10px;
  border-radius: 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.data-table .state-pill.queued    { background: #eef4fd; color: #1170cf; }
.data-table .state-pill.in_flight { background: #fff4d6; color: #8a5a00; }
.data-table .state-pill.retrying  { background: #fff4d6; color: #8a5a00; }
.data-table .state-pill.delivered { background: #cef5eb; color: #185e46; }
.data-table .state-pill.failed    { background: #ffe8ea; color: #ab0a15; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.stat-card {
  padding: 12px 16px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
}
.stat-card .k { font-size: 11px; color: #A4A7AE; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .v { font-size: 20px; font-weight: 600; color: #181D27; font-family: 'JetBrains Mono', monospace; }

.payload-pre {
  background: #f8f9fa;
  border: 1px solid #D5D7DA;
  border-radius: 8px;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  color: #181D27;
  max-height: 400px;
  overflow: auto;
}
