@import url('/vendor/roboto/roboto.css');

:root {
  --primary: #ED1C24;
  --primary-dark: #c2161c;
  --bg: #f4f4f4;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d7dce5;
  --sidebar-w: 240px;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 .125rem .35rem rgba(15, 23, 42, .08);
  font-family: "Roboto", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #050505;
  color: #fff;
  transition: transform .25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.brand-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  line-height: 1.1;
}

.brand-text strong {
  font-size: 14px;
}

.brand-text small {
  color: rgba(255, 255, 255, .52);
  font-size: 11px;
}

.nav {
  flex: 1;
  padding: 8px 0;
}

.nav-group {
  padding: 13px 18px 5px;
  color: rgba(255, 255, 255, .48);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  padding: 8px 18px 8px 15px;
  background: transparent;
  color: rgba(255, 255, 255, .58);
  text-align: left;
  font-size: 13.5px;
  transition: color .15s, background .15s, border-color .15s;
}

.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .07);
}

.nav button.active {
  color: #fff;
  background: rgba(237, 28, 36, .12);
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav .bi {
  width: 16px;
  color: inherit;
  opacity: .72;
  font-size: 15px;
}

.nav button.active .bi {
  opacity: 1;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, .18);
}

.sidebar-footer label,
.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.sidebar-footer label {
  color: rgba(255, 255, 255, .38);
}

select,
input,
textarea {
  width: 100%;
  min-height: 31px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 5px 9px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(237, 28, 36, .12);
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  background: var(--bg);
}

.icon-button {
  position: relative;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0;
  background: #fff;
  color: #374151;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.icon-button:hover {
  border-color: #c9d2df;
  background: #f8fafc;
}

.notif-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--primary);
}

.mobile-menu-btn {
  display: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

.user-avatar {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.user-chip span:last-child {
  display: grid;
  gap: 1px;
  line-height: 1.05;
}

.user-chip strong {
  font-size: 13px;
  font-weight: 500;
}

.user-chip small {
  color: var(--muted);
  font-size: 11px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 0;
  padding: 12px 24px 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #888;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
  font-weight: 700;
}

h2,
h3 {
  margin: 0;
}

.page-subtitle {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.page-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.ghost-button {
  min-height: 31px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 13px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.ghost-button {
  border-color: var(--line-strong);
  background: #fff;
  color: #374151;
}

.ghost-button:hover {
  background: #f8fafc;
}

.rule-actions-cell {
  width: 1%;
  white-space: nowrap;
}

.action-menu {
  position: relative;
  display: inline-block;
}

.action-menu-toggle {
  list-style: none;
}

.action-menu-toggle::-webkit-details-marker {
  display: none;
}

.action-menu[open] .action-menu-toggle {
  border-color: #c9d2df;
  background: #f8fafc;
}

.action-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  bottom: auto;
  z-index: 20;
  min-width: 180px;
  display: none;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .16);
}

.action-menu[open] .action-menu-panel {
  display: grid;
  gap: 2px;
}

.action-menu.menu-up .action-menu-panel {
  top: auto;
  bottom: calc(100% + 6px);
}

.action-menu-item {
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  justify-content: flex-start;
  text-align: left;
  box-shadow: none;
}

.action-menu-item:hover {
  background: #f3f4f6;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 0 24px 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.content {
  display: grid;
  gap: 16px;
  padding: 0 24px 28px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi,
.panel,
.card {
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 116px;
  padding: 18px;
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  margin-top: 9px;
  font-size: 28px;
  line-height: 1.1;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

.compact-table {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.compact-table table {
  min-width: 560px;
}

.compact-table th,
.compact-table td {
  padding: .58rem .7rem;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: .72rem .85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #4b5563;
  background: #f8f9fa;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

tr:hover td {
  background: #fcfcfc;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  background: #f0f0f0;
  color: #555;
  white-space: nowrap;
}

.badge.high {
  background: #fff0f0;
  color: var(--primary);
}

.badge.medium {
  background: #fffbeb;
  color: #d97706;
}

.badge.ok {
  background: #f0fdf4;
  color: #16a34a;
}

.badge.paused {
  background: #eff6ff;
  color: #2563eb;
}

.progress {
  height: 8px;
  min-width: 110px;
  margin-bottom: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #eceff3;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.bars {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 74px minmax(120px, 1fr) 70px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 24px;
  overflow: hidden;
  border-radius: var(--radius);
  background: #f0f0f0;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(237, 28, 36, .82);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 16px;
}

.card {
  padding: 16px;
}

.card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.detail span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .50);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

.modal header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal h2 {
  font-size: 18px;
}

#modalBody {
  padding: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.rule-form h3 {
  margin-top: 8px;
  font-size: 15px;
}

.switch-field,
.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.switch-field {
  min-height: 64px;
  padding: 12px;
}

.switch-field input,
.check-field input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.switch-field span {
  display: grid;
  gap: 3px;
}

.switch-field small {
  color: var(--muted);
  font-size: 12px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-field {
  min-height: 38px;
  padding: 8px 10px;
}

.empty {
  padding: 22px;
  color: var(--muted);
}

.demo-page {
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.demo-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.demo-actions[hidden] {
  display: none;
}

.demo-notice {
  margin: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(220, 38, 38, .24);
  border-radius: 16px;
  color: #991b1b;
  background: rgba(254, 226, 226, .72);
}

.demo-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 0;
}

.demo-tabs button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  background: #fff;
  color: #374151;
}

.demo-tabs button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.demo-tabs .link-button {
  margin-left: auto;
}

.demo-section {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.demo-section[hidden] {
  display: none;
}

.demo-section h3 {
  margin: 0;
}

.demo-migration-list,
.demo-history-list {
  display: grid;
  gap: 12px;
}

.demo-migration-card,
.demo-history-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
}

.demo-migration-card h4 {
  margin: 0 0 6px;
}

.demo-migration-card p,
.demo-history-card p {
  margin: 0;
  color: var(--muted);
}

.demo-migration-card small {
  display: inline-flex;
  margin-top: 8px;
  color: var(--muted);
}

.demo-migration-run {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.demo-migration-status {
  max-width: 260px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.demo-migration-status:empty {
  display: none;
}

.demo-migration-status[data-status="progress"] {
  color: #d97706;
}

.demo-migration-status[data-status="success"] {
  color: #16a34a;
}

.demo-migration-status[data-status="failed"] {
  color: var(--primary);
}

.demo-history-card {
  align-items: center;
}

.demo-history-card > div {
  display: grid;
  gap: 4px;
}

.demo-history-card span:not(.badge) {
  color: var(--muted);
  font-size: 13px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

button:disabled,
.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: .48;
  filter: grayscale(.35);
  box-shadow: none;
  transform: none;
}

button:disabled:hover,
.primary-button:disabled:hover,
.ghost-button:disabled:hover,
.icon-button:disabled:hover {
  transform: none;
  box-shadow: none;
}

.v2-overlay {
  position: fixed;
  inset: 0;
  z-index: 1035;
  display: none;
  background: rgba(0, 0, 0, .50);
}

.v2-overlay.open {
  display: block;
}

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .filters,
  .kpi-grid,
  .split,
  .details-grid,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    flex-direction: column;
    padding: 20px 16px 14px;
  }

  .filters,
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 640px) {
  .user-chip span:last-child {
    display: none;
  }

  h1 {
    font-size: 24px;
  }
}
