/* ============================
   OCTOSYNC ADMIN - styles
   Mobile-first. Panel oscuro futurista.
   ============================ */

:root {
  --bg:        #0B0B0F;
  --bg-2:      #101018;
  --bg-3:      #14141E;
  --surface:   #16161F;
  --surface-2: #1B1B27;
  --line:      rgba(255,255,255,.08);
  --line-2:    rgba(255,255,255,.14);

  --text:      #E8E9EE;
  --text-dim:  #A4A6B3;
  --muted:     #6E7184;

  --primary:   #3B82F6;
  --primary-2: #7C3AED;
  --green:     #34D399;
  --red:       #F87171;
  --amber:     #FBBF24;

  --grad: linear-gradient(135deg, #3B82F6 0%, #7C3AED 100%);
  --grad-soft: linear-gradient(135deg, rgba(59,130,246,.18), rgba(124,58,237,.18));

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);

  --sidebar-w: 240px;
  --topbar-h: 60px;

  --ff-display: 'Space Grotesk', system-ui, sans-serif;
  --ff-body:    'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
ul, ol { list-style: none; padding: 0; margin: 0; }
h1,h2,h3 { font-family: var(--ff-display); font-weight: 600; margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; letter-spacing: -.005em; }
h3 { font-size: .95rem; }
p, small { color: var(--text-dim); }
small { font-size: .8rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

code {
  background: rgba(255,255,255,.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .85em;
  color: #C4B5FD;
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #08080C;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 60;
}
.sidebar.is-open { transform: translateX(0); }

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-family: var(--ff-display); font-size: 1.1rem;
  padding: 6px 8px; margin-bottom: 18px;
}
.brand-mark { display: inline-flex; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: .92rem;
  transition: background .2s, color .2s;
}
.side-nav a:hover { background: rgba(255,255,255,.04); color: var(--text); }
.side-nav a.is-active {
  background: var(--grad-soft);
  color: var(--text);
  border: 1px solid rgba(124,58,237,.25);
}

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.03);
}
.user-pill strong { display: block; font-size: .9rem; }
.user-pill small { display: block; font-size: .72rem; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 700; font-family: var(--ff-display);
}
.logout {
  text-align: center; padding: 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); color: var(--text-dim);
  font-size: .85rem; transition: color .2s, border-color .2s;
}
.logout:hover { color: var(--text); border-color: var(--text-dim); }

/* ============================
   TOPBAR
   ============================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  background: rgba(11,11,15,.75);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 1.1rem; margin: 0; flex: 1; }
.topbar-cta { display: flex; gap: 8px; }
.menu-toggle {
  display: inline-flex; flex-direction: column; gap: 4px;
  width: 38px; height: 38px; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,.02);
}
.menu-toggle span { width: 16px; height: 2px; background: var(--text); border-radius: 2px; }

/* ============================
   CONTENT
   ============================ */
.content { padding: 18px 16px 60px; display: grid; gap: 16px; }

/* ============================
   BUTTONS
   ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  font-weight: 600; font-size: .9rem;
  transition: transform .2s, box-shadow .2s, background .2s, border-color .2s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-lg { padding: 13px 20px; font-size: .95rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(59,130,246,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(124,58,237,.4); }
.btn-ghost { background: rgba(255,255,255,.04); border-color: var(--line-2); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.08); }

.link {
  background: none; border: 0; padding: 0;
  color: #93C5FD; font-size: .85rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { color: #BFDBFE; }
.link-danger { color: #FCA5A5; }
.link-danger:hover { color: #FECACA; }

/* ============================
   PANELS / KPIS
   ============================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.panel-head .small { font-size: .82rem; }

.kpi-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, 1fr);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.kpi-card small { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.kpi-card strong {
  display: block; font-family: var(--ff-display); font-size: 1.4rem;
  margin: 6px 0 4px;
}
.kpi-card .up { color: var(--green); font-size: .78rem; }
.kpi-card .down { color: var(--red); font-size: .78rem; }

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

/* ============================
   TABLES
   ============================ */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
  vertical-align: middle;
}
.table th {
  font-weight: 600; color: var(--text-dim); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .08em;
  background: rgba(255,255,255,.02);
}
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table .actions { white-space: nowrap; display: flex; gap: 12px; align-items: center; }
.row-actions { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================
   BADGES
   ============================ */
.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: rgba(255,255,255,.06);
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.badge-blue   { background: rgba(59,130,246,.16); color: #93C5FD; border-color: rgba(59,130,246,.3); }
.badge-purple { background: rgba(124,58,237,.16); color: #C4B5FD; border-color: rgba(124,58,237,.3); }
.badge-green  { background: rgba(52,211,153,.14); color: #6EE7B7; border-color: rgba(52,211,153,.3); }
.badge-red    { background: rgba(248,113,113,.12); color: #FCA5A5; border-color: rgba(248,113,113,.3); }

/* ============================
   FORMS
   ============================ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .82rem; color: var(--text-dim); }
.field input, .field select, .field textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: rgba(124,58,237,.6);
  box-shadow: 0 0 0 3px rgba(124,58,237,.18);
}

.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

.form-alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .88rem;
  border: 1px solid;
  margin-bottom: 4px;
}
.form-alert.ok    { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.4); color: #6EE7B7; }
.form-alert.error { background: rgba(248,113,113,.08); border-color: rgba(248,113,113,.4); color: #FCA5A5; }

/* ============================
   LISTS / MISC
   ============================ */
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.mini-list strong { display: block; font-size: .9rem; }
.mini-list small  { display: block; color: var(--muted); font-size: .76rem; }

.legend { display: flex; gap: 14px; margin-top: 10px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-blue   { background: var(--primary); box-shadow: 0 0 8px rgba(59,130,246,.6); }
.dot-purple { background: var(--primary-2); box-shadow: 0 0 8px rgba(124,58,237,.6); }

.big-chart { width: 100%; height: 160px; }

.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-list li { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; }
.bar { height: 8px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; }
.bar > span {
  display: block; height: 100%;
  background: var(--grad);
  border-radius: 999px;
  transition: width .4s ease;
}

/* ============================
   LOGIN
   ============================ */
.login-body { background: var(--bg); min-height: 100vh; }
.login-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.login-bg .orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55;
}
.login-bg .orb-1 { width: 320px; height: 320px; top: -80px; left: -60px; background: #3B82F6; }
.login-bg .orb-2 { width: 360px; height: 360px; bottom: -120px; right: -80px; background: #7C3AED; opacity: .45; }
.login-bg .grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 70%);
}

.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px;
  gap: 24px;
}
.brand-center { font-size: 1.4rem; }
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 20px 60px rgba(59,130,246,.18);
}
.login-card h1 { font-family: var(--ff-display); font-size: 1.6rem; margin: 0 0 4px; }
.login-card .muted { margin: 0 0 18px; }
.login-hint {
  margin-top: 16px; font-size: .8rem; color: var(--muted); text-align: center;
  padding: 10px; border-radius: 8px;
  background: rgba(255,255,255,.02); border: 1px dashed var(--line-2);
}

/* ============================
   RESPONSIVE
   ============================ */
@media (min-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .content { padding: 24px; gap: 20px; }
}

@media (min-width: 900px) {
  body { padding-left: var(--sidebar-w); }
  .sidebar { transform: none; }
  .menu-toggle { display: none; }
  .topbar { padding: 0 28px; }
  .grid-2 { grid-template-columns: 1.4fr 1fr; }
  h1 { font-size: 1.6rem; }
  .table { min-width: 0; }
  .table-wrap { margin: 0; padding: 0; overflow-x: visible; }
}
