:root {
  --bg: #07101f;
  --panel: #101c2fdd;
  --line: #21314a;
  --text: #f4f8ff;
  --muted: #8fa2bb;
  --primary: #7c5cff;
  --cyan: #16d9c5;
  --danger: #ff6174;
  --warning: #ffb547;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #132648 0, #07101f 42%, #050b16 100%);
  color: var(--text);
  font-family: Cairo, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.13;
  pointer-events: none;
}

.glow-one {
  width: 420px;
  height: 420px;
  background: #785cff;
  top: -180px;
  right: -100px;
}

.glow-two {
  width: 380px;
  height: 380px;
  background: #00d5c3;
  bottom: -200px;
  left: -100px;
}

/* Auth Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px 14px;
}

.login-card {
  width: min(440px, 100%);
  background: linear-gradient(145deg, #15233aee, #0c1729ee);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 24px;
  box-shadow: 0 30px 80px #0007;
  text-align: center;
}

.logo {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  margin: auto;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), #b55cff);
  box-shadow: 0 12px 35px #795cff66;
  font-size: 30px;
}

.logo.small {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 12px;
  font-size: 20px;
}

.eyebrow {
  color: #a998ff;
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 800;
  margin: 12px 0 4px;
}

.muted,
.panel-head p,
.empty p {
  color: var(--muted);
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  margin-top: 16px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #091426;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px #7c5cff22;
}

.primary,
.ghost,
.logout,
nav button,
.icon {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.primary {
  border: 0;
  border-radius: 12px;
  color: white;
  background: linear-gradient(135deg, var(--primary), #9e58ff);
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 9px 25px #785cff35;
  transition: transform 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary:active {
  transform: scale(0.98);
}

.wide {
  width: 100%;
  margin-top: 22px;
  padding: 13px 20px;
}

.error {
  color: #ff8493;
  font-size: 12px;
  min-height: 18px;
  margin: 8px 0 0;
}

/* App Layout */
.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

/* Sidebar Desktop */
aside {
  padding: 24px 18px;
  border-left: 1px solid var(--line);
  background: #081322f2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.aside-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.close-sidebar {
  display: none;
  background: #17253a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 10px;
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 32px;
}

nav button {
  border: 0;
  text-align: right;
  padding: 12px 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

nav button:hover,
nav button.active {
  background: #7c5cff1c;
  color: #cfc6ff;
}

.side-status {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: #0b172a88;
}

.side-status small {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 15px var(--cyan);
}

.logout {
  margin-top: 10px;
  border: 1px solid #ff617422;
  border-radius: 10px;
  background: #ff61740d;
  color: #ff8493;
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.logout:hover {
  background: #ff61741f;
}

/* Main Area */
main {
  padding: 32px clamp(16px, 3vw, 48px);
  max-width: 1500px;
  width: 100%;
  margin: auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

.mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #101f35;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px #0003;
}

.mobile-toggle:active {
  transform: scale(0.95);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

header h1 {
  font-size: 26px;
  margin-bottom: 0;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 24px 0;
}

.stats article,
.panel {
  background: linear-gradient(145deg, #122039dd, #0c1728dd);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.stats article {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.stats article:after {
  content: "";
  position: absolute;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background: #7c5cff22;
  left: -15px;
  top: -15px;
}

.stats span,
.stats small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats strong {
  display: block;
  font-size: 26px;
  margin: 6px 0;
}

.panel {
  padding: 22px;
  margin-bottom: 20px;
}

.panel-head p {
  font-size: 12px;
  margin: 4px 0 0;
}

.ghost {
  border: 1px solid var(--line);
  background: #0b1728;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
}

.empty {
  text-align: center;
  padding: 50px 16px;
}

.empty span {
  font-size: 42px;
}

/* Jobs */
.jobs {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.job {
  border: 1px solid var(--line);
  background: #09142699;
  border-radius: 15px;
  padding: 16px;
}

.job-top,
.job-meta,
.job-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.job h3 {
  font-size: 15px;
  margin: 0;
}

.job-url {
  direction: ltr;
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 550px;
  margin-top: 4px;
}

.badge {
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.running {
  background: #16d9c51c;
  color: var(--cyan);
}

.completed {
  background: #7c5cff22;
  color: #b9acff;
}

.failed {
  background: #ff61741c;
  color: #ff8493;
}

.stopped {
  background: #ffb5471c;
  color: var(--warning);
}

.pending {
  background: #8fa2bb1c;
  color: #b9c7d8;
}

.progress {
  height: 7px;
  background: #17253a;
  border-radius: 99px;
  overflow: hidden;
  margin: 14px 0;
}

.progress div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  border-radius: 99px;
  transition: width 0.4s;
}

.job-meta {
  color: var(--muted);
  font-size: 11px;
  flex-wrap: wrap;
}

.stop {
  border: 0;
  background: #ff617418;
  color: #ff8493;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
}

/* Dialogs */
dialog {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #0d192b;
  color: var(--text);
  width: min(760px, calc(100% - 24px));
  max-height: 88vh;
  overflow-y: auto;
  padding: 0;
  margin: auto;
  box-shadow: 0 30px 100px #000b;
}

dialog::backdrop {
  background: #02060dcc;
  backdrop-filter: blur(6px);
}

dialog form {
  padding: 24px 20px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid small {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
}

.dialog-actions {
  justify-content: flex-start;
  gap: 10px;
  margin-top: 24px;
}

.toast {
  position: fixed;
  left: 20px;
  bottom: 24px;
  background: #15233a;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 18px;
  transform: translateY(100px);
  opacity: 0;
  transition: 0.25s;
  z-index: 1000;
  font-size: 13px;
  box-shadow: 0 10px 30px #0008;
}

.toast.show {
  transform: none;
  opacity: 1;
}

/* Mobile Drawer & Backdrop */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: #02060db3;
  backdrop-filter: blur(5px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.nav-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
}

/* ==========================================================================
   Responsive Breakpoints (Mobile & Tablet)
   ========================================================================== */

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  /* Slide-in Drawer for Sidebar */
  aside {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 290px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: #0a1526;
    border-left: 1px solid var(--line);
    border-right: none;
    z-index: 120;
    transform: translateX(105%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -15px 0 40px #000c;
    overflow-y: auto;
    padding: 20px 16px;
  }

  aside.open {
    transform: translateX(0);
  }

  .close-sidebar {
    display: flex;
  }

  .mobile-toggle {
    display: flex;
  }

  main {
    padding: 18px 14px 84px 14px;
  }

  /* Mobile Bottom App Bar */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #091426f5;
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
    z-index: 90;
    padding: 4px 6px;
    box-shadow: 0 -8px 30px #0009;
  }

  .mobile-bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    padding: 6px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
  }

  .mobile-bottom-nav button:active {
    background: #7c5cff15;
  }

  .mobile-bottom-nav button.active {
    color: #16d9c5;
    font-weight: 700;
  }

  .mobile-bottom-nav .nav-icon {
    font-size: 18px;
    line-height: 1;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 18px 0;
  }

  .stats article {
    padding: 14px 12px;
    border-radius: 14px;
  }

  .stats strong {
    font-size: 22px;
  }

  header h1 {
    font-size: 22px;
  }

  .panel {
    padding: 16px 14px;
    border-radius: 16px;
  }

  .job-url {
    max-width: 100%;
    white-space: normal;
    word-break: break-all;
  }
}

@media (max-width: 560px) {
  .header-left div {
    min-width: 0;
  }

  header h1 {
    font-size: 19px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .primary {
    padding: 10px 14px;
    font-size: 13px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .full {
    grid-column: auto;
  }

  .job-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .job-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .job-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
    padding: 12px;
  }
}
