/* Oruve Dashboard — Stripe-inspired design system */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --color-bg:           #f6f9fc;
  --color-surface:      #ffffff;
  --color-border:       #e3e8ee;
  --color-border-light: #f0f4f8;

  --color-text:         #1a1f36;
  --color-text-muted:   #6b7280;
  --color-text-subtle:  #9ca3af;

  --color-primary:      #0570de;
  --color-primary-dark: #0459b0;
  --color-primary-bg:   #eff8ff;

  --color-green:        #0e6245;
  --color-green-bg:     #d1fae5;
  --color-red:          #991b1b;
  --color-red-bg:       #fee2e2;
  --color-yellow:       #7c5b00;
  --color-yellow-bg:    #fef3c7;
  --color-blue:         #1d4ed8;
  --color-blue-bg:      #dbeafe;
  --color-purple:       #5b21b6;
  --color-purple-bg:    #ede9fe;
  --color-orange:       #92400e;
  --color-orange-bg:    #ffedd5;
  --color-gray:         #374151;
  --color-gray-bg:      #f3f4f6;

  --sidebar-width:      220px;
  --topbar-height:      56px;

  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  8px;

  --shadow-sm:  0 1px 3px 0 rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.07);

  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

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

html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.content {
  padding: 32px 24px;
  max-width: 1200px;
  width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--color-border-light);
  text-decoration: none;
  gap: 10px;
}

.sidebar-logo-mark {
  width: 28px;
  height: 28px;
  background: var(--color-primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.2;
}

.sidebar-logo-role {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.nav-section {
  padding: 8px 8px 0;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}

.nav-item:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.nav-item--active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item--active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--color-border-light);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  text-decoration: none;
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Topbar ──────────────────────────────────────────── */

.topbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  min-width: 0;
  flex: 1;
}

.topbar-breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.topbar-breadcrumb a:hover { color: var(--color-text); }

.topbar-breadcrumb-sep { color: var(--color-border); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ── Page header ─────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 3px;
}

/* ── Cards ───────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}

.card-body {
  padding: 20px;
}

/* ── Stat cards ──────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1;
}

.stat-change {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.stat-change--up   { color: var(--color-green); }
.stat-change--down { color: var(--color-red); }

/* ── Tables ──────────────────────────────────────────── */

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  background: var(--color-surface);
}

tbody tr {
  border-bottom: 1px solid var(--color-border-light);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--color-bg); }

tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  color: var(--color-text);
  font-size: 0.82rem;
}

td.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.table-link {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

.table-link:hover { color: var(--color-primary); text-decoration: underline; }

.table-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

/* ── Badges ──────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge--green  { background: var(--color-green-bg);  color: var(--color-green); }
.badge--red    { background: var(--color-red-bg);    color: var(--color-red); }
.badge--yellow { background: var(--color-yellow-bg); color: var(--color-yellow); }
.badge--blue   { background: var(--color-blue-bg);   color: var(--color-blue); }
.badge--purple { background: var(--color-purple-bg); color: var(--color-purple); }
.badge--orange { background: var(--color-orange-bg); color: var(--color-orange); }
.badge--gray   { background: var(--color-gray-bg);   color: var(--color-gray); }

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s, box-shadow 0.1s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--color-bg);
  border-color: #cdd5df;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-sm {
  padding: 4px 10px;
  font-size: 0.76rem;
}

/* ── Forms ───────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 5px;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.1s, box-shadow 0.1s;
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(5,112,222,.15);
}

.form-control::placeholder { color: var(--color-text-subtle); }

select.form-control { cursor: pointer; }

.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: #0570de;
  box-shadow: 0 0 0 3px rgba(5, 112, 222, 0.1);
}

/* Utility classes */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
}

/* ── Alerts ──────────────────────────────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  border: 1px solid transparent;
}

.alert-icon { flex-shrink: 0; margin-top: 1px; }

.alert-info    { background: var(--color-blue-bg);   border-color: #bfdbfe; color: var(--color-blue); }
.alert-success { background: var(--color-green-bg);  border-color: #6ee7b7; color: var(--color-green); }
.alert-warning { background: var(--color-yellow-bg); border-color: #fde68a; color: var(--color-yellow); }
.alert-error   { background: var(--color-red-bg);    border-color: #fecaca; color: var(--color-red); }

/* ── Timeline ────────────────────────────────────────── */

.timeline {
  list-style: none;
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
  padding-left: 16px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -14px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
}

.timeline-dot--active {
  border-color: var(--color-primary);
  background: var(--color-primary);
}

.timeline-dot--success {
  border-color: var(--color-green);
  background: var(--color-green);
}

.timeline-dot--error {
  border-color: var(--color-red);
  background: var(--color-red);
}

.timeline-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text);
}

.timeline-time {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.timeline-body {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ── Detail grid ─────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0;
}

.detail-row {
  display: contents;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 10px 20px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg);
}

.detail-value {
  font-size: 0.82rem;
  color: var(--color-text);
  padding: 10px 20px;
  border-bottom: 1px solid var(--color-border-light);
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table tr:last-child .detail-label,
.detail-table tr:last-child .detail-value {
  border-bottom: none;
}

/* ── Filters bar ─────────────────────────────────────── */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-subtle);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(5,112,222,.12);
  background: var(--color-surface);
}

/* ── Section spacing ─────────────────────────────────── */

.section + .section { margin-top: 28px; }

/* ── Capability tiles ────────────────────────────────── */

.capability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px 20px;
}

.capability-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.capability-item-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.capability-item-value {
  font-size: 0.82rem;
  color: var(--color-text);
  font-weight: 500;
}

/* ── Login page ──────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.login-header {
  padding: 32px 32px 0;
  text-align: center;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.login-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.login-logo-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
}

.login-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 5px;
}

.login-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0;
}

.login-body {
  padding: 24px 32px 32px;
}

/* ── Routing rule rows ───────────────────────────────── */

.rule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border-light);
}

.rule-row:last-child { border-bottom: none; }

.rule-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  flex: 1;
}

.rule-value {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-align: right;
}

/* ── Toggle switch ───────────────────────────────────── */

.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  left: 3px;
  top: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--color-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Loading / skeleton ──────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--color-border-light) 25%, var(--color-border) 50%, var(--color-border-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Utility ─────────────────────────────────────────── */

.text-muted   { color: var(--color-text-muted); }
.text-subtle  { color: var(--color-text-subtle); }
.text-right   { text-align: right; }
.text-mono    { font-family: var(--font-mono); font-size: 0.78rem; }
.fw-500       { font-weight: 500; }
.fw-600       { font-weight: 600; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* ── Badge styles ────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

.badge-blue {
  background: #dbeafe;
  color: #0c4a6e;
}

.badge-gray {
  background: #f3f4f6;
  color: #6b7280;
}

/* ── Version History ─────────────────────────────────── */

.version-diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 12px;
}

.version-diff-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  color: #6b7280;
  font-weight: 600;
  background: #f9fafb;
}

.version-diff-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f3f4f6;
  font-family: var(--font-mono);
  word-break: break-word;
}

.diff-changed td {
  background: #fefce8;
}

.diff-changed td:first-child {
  font-weight: 600;
  color: #854d0e;
}

dialog {
  border: none !important;
  border-radius: 8px !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
  padding: 0 !important;
  margin: 0 !important;
  position: fixed !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 1000 !important;
}

dialog[open] {
  display: flex !important;
}

dialog > div {
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px !important;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

dialog h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 1.125rem;
}

dialog p {
  margin: 0 0 16px 0;
  color: #6b7280;
  font-size: 0.88rem;
}
