:root {
  --bg: #090d16;
  --panel: #111827;
  --panel-alt: #172033;
  --border: #1f2937;
  --border-light: #374151;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --emerald: #10b981;
  --danger: #ef4444;
  --blue: #3b82f6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(17, 24, 39, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
  gap: 12px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #090d16;
  font-weight: 900;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel-alt);
  border: 1px solid var(--border-light);
  color: var(--muted);
}
.badge.amber { color: #fbbf24; border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.12); }
.badge.green { color: #34d399; border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.12); }
.badge.blue { color: #60a5fa; border-color: rgba(59, 130, 246, 0.4); background: rgba(59, 130, 246, 0.12); }

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 22px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 8px 15px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); background: var(--panel); }
.tab-btn.active {
  background: var(--panel-alt);
  color: var(--accent);
  border-color: rgba(245, 158, 11, 0.4);
}

.grid {
  display: grid;
  gap: 18px;
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.card h3 { margin: 0 0 8px 0; font-size: 17px; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border-light);
  background: var(--panel-alt);
  color: var(--text);
  transition: 0.15s ease;
}
.btn:hover { border-color: var(--muted); }
.btn.primary {
  background: linear-gradient(90deg, #f59e0b, #ea580c);
  color: #090d16;
  border: none;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:hover td { background: rgba(255, 255, 255, 0.015); }

.kanban-wrap {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(270px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}
.kanban-col {
  background: rgba(17, 24, 39, 0.75);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.kanban-card {
  background: var(--panel-alt);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  cursor: grab;
}
.kanban-card:hover { border-color: var(--accent); }
.kanban-card-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.kanban-transitions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
  margin: 6px 0;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-top: 6px;
}
.bar-track {
  flex: 1;
  height: 7px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
}

.timeline-item {
  border-left: 2px solid var(--border-light);
  padding: 6px 0 16px 16px;
  position: relative;
}
.timeline-item::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: -6px;
  top: 10px;
}

.code-box {
  background: #05080f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 22px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel-alt);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  z-index: 99;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5);
  display: none;
}
.toast.show { display: block; }

/* Multi-device mobile frame & responsive bottom bar */
.mobile-preview-shell {
  max-width: 410px;
  margin: 18px auto;
  border: 6px solid #1f2937;
  border-radius: 34px;
  background: var(--bg);
  min-height: 760px;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
}
.mobile-preview-shell .container { padding: 14px; }
.mobile-preview-shell .kanban-wrap { grid-auto-columns: minmax(240px, 85%); }
.mobile-preview-shell .grid-2,
.mobile-preview-shell .grid-3,
.mobile-preview-shell .grid-4 { grid-template-columns: 1fr; }
.mobile-bottom-nav {
  display: none;
  position: sticky;
  bottom: 0;
  background: #0f172a;
  border-top: 1px solid var(--border);
  padding: 8px;
  gap: 6px;
  overflow-x: auto;
}
.mobile-preview-shell .mobile-bottom-nav { display: flex; }
@media (max-width: 768px) {
  .container { padding: 14px; }
  .mobile-bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; }
}
