/* ClipDesk — control-room aesthetic.
   Deep slate ground, signal-cyan for live state, amber for waiting,
   coral for failure. Type: Space Grotesk display / Inter body /
   JetBrains Mono for anything numeric. */

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

:root {
  --ink:        #0B0F14;
  --panel:      #121820;
  --panel-2:    #182029;
  --line:       #232E3A;
  --line-soft:  #1B242E;

  --text:       #E6EDF5;
  --text-dim:   #8C9BAB;
  --text-faint: #5A6875;

  --signal:     #38E1C4;
  --signal-dim: #1B7A6B;
  --amber:      #F5B841;
  --coral:      #FF6B5E;
  --violet:     #9D8DF1;

  --r:    10px;
  --r-sm: 6px;

  --display: 'Space Grotesk', system-ui, sans-serif;
  --body:    'Inter', system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, monospace;

  --nav-w: 232px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--signal-dim); color: #fff; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

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

.shell { display: block; min-height: 100vh; }

.nav {
  width: var(--nav-w);
  background: var(--panel);
  border-right: 1px solid var(--line-soft);
  padding: 20px 14px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 40;
  transition: transform .28s var(--ease);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 22px;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--signal), var(--violet));
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; color: var(--ink);
  font-size: 15px;
}
.brand-name {
  font-family: var(--display); font-weight: 600;
  font-size: 16px; letter-spacing: -.01em;
}

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--text-dim); font-weight: 500; font-size: 13.5px;
  transition: background .16s, color .16s;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.on { background: var(--panel-2); color: var(--text); }
.nav-link.on .ic { color: var(--signal); }
.ic { width: 17px; height: 17px; flex: 0 0 17px; color: var(--text-faint); }

.nav-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-soft); }

.main {
  margin-left: var(--nav-w);
  padding: 26px 30px 60px;
  max-width: 1500px;
  min-width: 0;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
h1 {
  font-family: var(--display); font-size: 22px;
  font-weight: 600; letter-spacing: -.02em;
}
.sub { color: var(--text-dim); font-size: 13px; margin-top: 3px; }

.menu-btn {
  display: none; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); width: 38px; height: 38px; border-radius: var(--r-sm);
  cursor: pointer; align-items: center; justify-content: center;
}

/* ---------- cards ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-title {
  font-family: var(--display); font-size: 14px; font-weight: 600;
  letter-spacing: .01em;
}

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

/* ---------- stat tiles ---------- */

.stat {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 15px 16px;
  position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent, var(--signal)); opacity: .8;
}
.stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-faint); font-weight: 600;
}
.stat-value {
  font-family: var(--mono); font-size: 25px; font-weight: 500;
  margin-top: 6px; letter-spacing: -.02em;
}
.stat-note { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

/* ---------- form ---------- */

label { display: block; font-size: 12.5px; font-weight: 500;
        color: var(--text-dim); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=url], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%; background: var(--ink);
  border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-sm); padding: 9px 11px;
  font-family: var(--body); font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(56,225,196,.12);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 72px; }

.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--signal); color: #06231F;
  border: none; border-radius: var(--r-sm);
  padding: 9px 15px; font-family: var(--body); font-size: 13.5px;
  font-weight: 600; cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost { background: var(--panel-2); color: var(--text);
             border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--line-soft); filter: none; }
.btn-danger { background: transparent; color: var(--coral);
              border: 1px solid rgba(255,107,94,.3); }
.btn-danger:hover { background: rgba(255,107,94,.1); filter: none; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 20px;
  text-transform: uppercase;
}
.badge.ok   { background: rgba(56,225,196,.12); color: var(--signal); }
.badge.warn { background: rgba(245,184,65,.12); color: var(--amber); }
.badge.bad  { background: rgba(255,107,94,.12); color: var(--coral); }
.badge.idle { background: var(--panel-2); color: var(--text-faint); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dot.live { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(56,225,196,.5); }
  50%     { opacity: .7; box-shadow: 0 0 0 5px rgba(56,225,196,0); }
}

/* ---------- progress ---------- */

.bar {
  height: 5px; background: var(--line-soft); border-radius: 3px;
  overflow: hidden; position: relative;
}
.bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--signal-dim), var(--signal));
  border-radius: 3px; transition: width .5s var(--ease);
}
.bar-fill.indet {
  width: 34% !important;
  animation: slide 1.5s var(--ease) infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); } 100% { transform: translateX(320%); }
}

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

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-faint); font-weight: 600;
  padding: 0 12px 9px; border-bottom: 1px solid var(--line-soft);
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(255,255,255,.015); }
.num { font-family: var(--mono); font-size: 12.5px; }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- misc ---------- */

.empty {
  text-align: center; padding: 40px 20px; color: var(--text-dim);
}
.empty-title {
  font-family: var(--display); font-size: 15px; color: var(--text);
  margin-bottom: 6px;
}

.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast-wrap {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--signal);
  border-radius: var(--r-sm); padding: 11px 14px;
  font-size: 13px; max-width: 340px;
  animation: rise .25s var(--ease);
  box-shadow: 0 8px 26px rgba(0,0,0,.4);
}
.toast.bad { border-left-color: var(--coral); }
.toast.warn { border-left-color: var(--amber); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--signal);
  animation: rot .7s linear infinite; display: inline-block;
}
@keyframes rot { to { transform: rotate(360deg); } }

.overlay {
  position: fixed; inset: 0; background: rgba(6,10,14,.7);
  backdrop-filter: blur(3px); z-index: 90; display: none;
}
.overlay.on { display: block; }

/* ---------- auth screens ---------- */

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 372px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 30px;
}
.auth-title {
  font-family: var(--display); font-size: 19px; font-weight: 600;
  margin-bottom: 4px;
}
.auth-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 22px; }
.auth-err {
  background: rgba(255,107,94,.1); border: 1px solid rgba(255,107,94,.25);
  color: var(--coral); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 12.5px; margin-bottom: 16px;
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .nav { transform: translateX(-100%); }
  .nav.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 18px 16px 60px; }
  .menu-btn { display: flex; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  h1 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
