:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --purple: #6d28d9;
  --purple-soft: #f5f3ff;
  --emerald: #047857;
  --emerald-soft: #ecfdf5;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --rose: #be123c;
  --rose-soft: #fff1f2;
  --navy: #0f172a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy);
  color: #f8fafc;
  border-bottom: 1px solid #1e293b;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clock-pill {
  background: #1e293b;
  border: 1px solid #334155;
  color: #38bdf8;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-bar input {
  background: #1e293b;
  border: 1px solid #334155;
  color: #f8fafc;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.875rem;
}

.auth-bar input::placeholder {
  color: #94a3b8;
}

.auth-bar input:focus {
  outline: 2px solid #38bdf8;
  border-color: #38bdf8;
}

/* Container */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 13px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-emerald {
  background: var(--emerald);
  color: #fff;
}
.btn-emerald:hover:not(:disabled) {
  background: #065f46;
}

.btn-danger {
  background: var(--rose);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #9f1239;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
  background: var(--surface-muted);
}

.btn-dark-outline {
  background: transparent;
  color: #e2e8f0;
  border-color: #475569;
}
.btn-dark-outline:hover:not(:disabled) {
  background: #1e293b;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.74rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-platform {
  background: #e2e8f0;
  color: #334155;
}

.badge-tenor {
  background: #0f172a;
  color: #ffffff;
  font-size: 0.84rem;
  padding: 3px 10px;
}

.badge-spread {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #bfdbfe;
}

.badge-fixed {
  background: var(--purple-soft);
  color: var(--purple);
  border: 1px solid #ddd6fe;
}

.badge-open {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid #a7f3d0;
}

.badge-urgent {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid #fde68a;
  animation: pulseBorder 1.8s infinite;
}

.badge-closed {
  background: #e2e8f0;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.badge-submitted {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.badge-recent {
  background: #fef08a;
  color: #854d0e;
  font-size: 0.7rem;
  padding: 1px 6px;
}

@keyframes pulseBorder {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 83, 9, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(180, 83, 9, 0.08); }
}

/* Cards & Panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-closed {
  opacity: 0.88;
  background: #f8fafc;
}

.card-submitted {
  border-color: #86efac;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface-muted);
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.issuer-name {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
}

.card-body {
  padding: 16px 18px;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.meta-strip strong {
  color: var(--text);
}

.ref-box {
  background: #f8fafc;
  border-left: 3px solid #94a3b8;
  padding: 7px 11px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  white-space: pre-line;
}

.macro-banner {
  background: #ffffff;
  border: 1px solid var(--border);
  border-left: 4px solid #64748b;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.86rem;
}

.macro-banner summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-secondary);
}

.macro-banner pre {
  margin: 8px 0 0;
  font-family: inherit;
  white-space: pre-wrap;
  color: var(--text);
}

/* Filter Bar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.chip-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* Bid Form Grid */
.bid-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bid-lines-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bid-line-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(130px, 0.9fr) minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 820px) {
  .bid-line-row {
    grid-template-columns: 1fr 1fr;
  }
}

.input-unit-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-unit-wrap input {
  width: 100%;
  padding: 8px 36px 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  background: #fff;
}

.input-unit-wrap input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.input-unit-wrap input:disabled {
  background: #f1f5f9;
  color: #64748b;
}

.input-unit {
  position: absolute;
  right: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

.memo-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.84rem;
}

.preview-pill {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 6px 9px;
  border-radius: 6px;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preview-pill.fixed {
  color: var(--purple);
  background: var(--purple-soft);
}

.preview-pill.empty {
  color: var(--text-muted);
  background: var(--surface-muted);
  font-weight: 400;
}

.card-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.auth-prompt-box {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
}

/* Admin Layout */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  margin-top: 4px;
  color: var(--text);
}

.admin-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 16px;
}

@media (max-width: 600px) {
  .admin-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
}

.row-recent {
  background: #fefce8;
}

/* Admin Parser Editor */
.split-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.textarea-notice {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: Consolas, "Malgun Gothic", monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  resize: vertical;
}

.edit-table-wrap {
  overflow-x: auto;
}

.edit-table input,
.edit-table select {
  padding: 5px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 0.8rem;
  width: 100%;
}

/* Login Box */
.login-box {
  max-width: 420px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-field label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-field input,
.form-field select {
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 0.92rem;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: #fff;
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 18px;
  font-size: 0.9rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-muted);
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--navy);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
}

.toast.success { background: #065f46; }
.toast.error { background: #9f1239; }
.toast.warn { background: #b45309; }

.test-mode-banner {
  background: linear-gradient(90deg, #7c3aed, #b45309);
  color: #ffffff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.btn-test-on {
  background: #f59e0b;
  color: #0f172a;
  border-color: #fbbf24;
}
.btn-test-on:hover:not(:disabled) {
  background: #fbbf24;
}

/* Admin Notification Bell & Dropdown */
.notif-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 370px;
  max-width: 92vw;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  overflow: hidden;
}

.notif-dropdown-header {
  padding: 10px 14px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
}

.notif-list {
  max-height: 340px;
  overflow-y: auto;
}

.notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.notif-item.unread {
  background: #fefce8;
}

.notif-item:last-child {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
