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

/* Dashboard v2 tokens. Source: FE-ADMIN-PANEL dashboardV2-tokens.css */
:root {
  --dv2-color-gray-500: #71717a;
  --dv2-color-gray-900: #18181b;
  --dv2-color-green-600: #15806b;
  --dv2-color-green-700: #11705b;
  --dv2-color-lavender-50: #f7f7fd;
  --dv2-color-lavender-100: #efeff6;
  --dv2-bg-page: var(--dv2-color-lavender-50);
  --dv2-text-primary: var(--dv2-color-gray-900);
  --dv2-text-secondary: var(--dv2-color-gray-500);
  --dv2-text-heading: #000;
  --dv2-accent-default: var(--dv2-color-green-700);
  --dv2-accent-strong: var(--dv2-color-green-600);
  --dv2-radius-md: 8px;
  --dv2-radius-full: 9999px;
  --dv2-font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --dv2-sidebar-bg: #106757;
  --dv2-sidebar-nav-bg: #0b493e;
  --dv2-sidebar-width: 260px;
  --dv2-shadow-neumorphic:
    -3px -3px 7px rgba(255, 255, 255, 0.9),
    3px 3px 7px rgba(204, 204, 224, 0.6);
  --dv2-shadow-neumorphic-inset:
    inset 3px 3px 6px rgba(204, 204, 224, 0.6),
    inset -3px -3px 6px rgba(255, 255, 255, 0.9);
  --dv2-shadow-sidebar-neumorphic-inset:
    inset 2px 2px 6px rgba(0, 0, 0, 0.35),
    inset -2px -2px 5px rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--dv2-bg-page);
  color: var(--dv2-text-primary);
  font-family: var(--dv2-font-family);
}

button, input { font-family: inherit; }

/* ------------------------------------------------------------------ gate */

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--dv2-bg-page);
}

.gate-card {
  width: min(420px, 100%);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--dv2-bg-page);
  box-shadow: var(--dv2-shadow-neumorphic);
  overflow: hidden;
}

.gate-brand {
  display: flex;
  align-items: center;
  height: 88px;
  padding: 0 28px;
  background: var(--dv2-sidebar-bg);
}

.gate-brand img { height: 28px; width: auto; }

.gate-body {
  display: grid;
  gap: 8px;
  padding: 24px 28px 28px;
}

.gate-body h1 {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--dv2-text-heading);
}

.gate-body p {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dv2-text-secondary);
}

.gate-body label {
  font-size: 13px;
  font-weight: 650;
}

.gate-body input {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--dv2-radius-md);
  background: var(--dv2-bg-page);
  color: var(--dv2-text-primary);
  font-size: 13px;
  box-shadow: var(--dv2-shadow-neumorphic);
}

.gate-body input:focus {
  outline: 2px solid var(--dv2-accent-default);
  outline-offset: 1px;
}

.gate-error {
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

.gate-body .bl-btn--primary {
  width: 100%;
  margin-top: 8px;
}

/* ------------------------------------------------------------------ shell */

.shell {
  display: flex;
  height: 100%;
  min-height: 100vh;
  background: var(--dv2-bg-page);
}

.sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--dv2-sidebar-width);
  min-height: 100%;
  padding: 22px 14px 20px;
  background: var(--dv2-sidebar-bg);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 20px;
  padding: 0 6px;
}

.sidebar__brand img { height: 30px; width: auto; }

.sidebar__panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  padding: 8px;
  border-radius: 16px;
  background: var(--dv2-sidebar-nav-bg);
  box-shadow: var(--dv2-shadow-sidebar-neumorphic-inset);
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.nav--active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 600;
  box-shadow:
    -1px -1px 4px rgba(255, 255, 255, 0.08),
    2px 2px 6px rgba(0, 0, 0, 0.28);
}

.sidebar__logout {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.sidebar__logout:hover { background: rgba(255, 255, 255, 0.1); }

.content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 24px;
}

.page {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-bottom: 24px;
}

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

.pagehead h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--dv2-text-heading);
}

.pagehead p,
.detail p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dv2-text-secondary);
}

.detail { margin-top: 24px; }

.detail h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--dv2-text-heading);
}

.detail p { margin-bottom: 12px; }

/* ------------------------------------------------------------------ alert */

.bl-alert {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff5f4;
  color: #7a271a;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ------------------------------------------------------------------ table */

.bl-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 18px;
  background: var(--dv2-bg-page);
  box-shadow: var(--dv2-shadow-neumorphic);
  font-size: 13px;
  color: var(--dv2-text-primary);
}

.bl-table th,
.bl-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--dv2-color-lavender-100);
}

.bl-table tbody tr:last-child td { border-bottom: 0; }

.bl-table thead th {
  padding-top: 14px;
  padding-bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--dv2-text-secondary);
}

.bl-table tbody tr { cursor: pointer; }

.bl-table tbody tr:hover td { background: rgba(255, 255, 255, 0.55); }

.bl-table tbody tr.is-selected td,
.bl-table tbody tr.is-selected:hover td {
  background: #e7f3ef;
}

.job {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.job-name {
  font-weight: 600;
  color: var(--dv2-text-heading);
}

.job-meta {
  margin-top: 6px;
  color: var(--dv2-text-secondary);
  font-size: 12px;
}

.when {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.schedule {
  font-weight: 600;
  color: var(--dv2-text-heading);
  white-space: nowrap;
}

.detail-line {
  margin: 0;
  max-width: 440px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dv2-text-primary);
}

.actions-cell { white-space: nowrap; text-align: right; }

.actions {
  display: inline-flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.bl-table .bl-btn {
  box-shadow:
    -2px -2px 5px rgba(255, 255, 255, 0.9),
    2px 2px 5px rgba(204, 204, 224, 0.55);
}

.bl-table .bl-btn--primary {
  box-shadow: 0 2px 6px rgba(17, 112, 91, 0.22);
}

/* ------------------------------------------------------------------ pills */

.bl-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--dv2-radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.bl-pill--neutral { background: var(--dv2-color-lavender-100); color: var(--dv2-text-secondary); }
.bl-pill--progress { background: #e8efff; color: #1d4ed8; }
.bl-pill--good { background: #e3f3ee; color: var(--dv2-accent-strong); }
.bl-pill--warn { background: #fdf0dd; color: #b54708; }
.bl-pill--bad { background: #fdeceb; color: #b42318; }

/* ------------------------------------------------------------------ buttons */

.bl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--dv2-radius-md);
  background: var(--dv2-bg-page);
  color: var(--dv2-text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--dv2-shadow-neumorphic);
  transition: transform 80ms ease-out, box-shadow 120ms ease-out;
}

.bl-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: var(--dv2-shadow-neumorphic-inset);
}

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

.bl-btn--primary {
  background: var(--dv2-accent-default);
  color: #fff;
}

.bl-btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

@media (max-width: 960px) {
  html, body { height: auto; min-height: 100%; }

  .gate {
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }

  .gate-body { padding: 20px 18px 22px; }

  .gate-body input { font-size: 16px; }

  .shell {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 0;
    padding:
      max(12px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      12px
      max(14px, env(safe-area-inset-left));
  }

  .sidebar__brand {
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  .sidebar__brand img { height: 22px; }

  .sidebar__panel { display: none; }

  .sidebar__logout {
    margin-top: 0;
    margin-left: auto;
    min-height: 44px;
    padding: 8px 10px;
  }

  .content {
    overflow: visible;
    padding:
      16px
      max(14px, env(safe-area-inset-right))
      max(28px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .pagehead {
    align-items: center;
    margin-bottom: 16px;
  }

  .pagehead h1 { font-size: 20px; }

  .bl-table,
  .bl-table tbody,
  .bl-table tr,
  .bl-table td {
    display: block;
    width: auto;
  }

  .bl-table thead { display: none; }

  .bl-table { font-size: 14px; }

  .bl-table tr {
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--dv2-color-lavender-100);
  }

  .bl-table tbody tr:last-child { border-bottom: 0; }

  .bl-table td {
    padding: 0;
    border: 0;
    white-space: normal;
  }

  #jobs tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
  }

  .job-cell,
  .schedule-cell,
  .actions-cell { grid-column: 1 / -1; }

  .job { width: 100%; }
  .job-name { flex: 1; min-width: 0; font-size: 15px; }

  .schedule {
    font-weight: 500;
    white-space: normal;
    color: var(--dv2-text-secondary);
  }

  #jobs td[data-label] {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  #jobs td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--dv2-text-secondary);
  }

  .when { white-space: normal; }

  .actions { display: flex; width: 100%; }

  .actions .bl-btn {
    flex: 1;
    height: 44px;
    font-size: 13px;
  }

  .bl-table tbody tr:hover { background: rgba(255, 255, 255, 0.55); }
  .bl-table tbody tr:hover td { background: transparent; }

  .bl-table tbody tr.is-selected,
  .bl-table tbody tr.is-selected:hover { background: #e7f3ef; }

  .bl-table tbody tr.is-selected td,
  .bl-table tbody tr.is-selected:hover td { background: transparent; }

  .detail .bl-table tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 8px;
  }

  .run-when { font-variant-numeric: tabular-nums; font-weight: 600; }

  .run-how { color: var(--dv2-text-secondary); }

  .run-what,
  .detail .bl-table td[colspan] { grid-column: 1 / -1; }

  .detail-line { max-width: none; }
}
