/* Loopario LCMS — App-Stil (Loopario Brand: Violett/Orange/Creme, Nunito) */
:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --ink: #190532;
  --ink-soft: #4a3a5e;
  --muted: #8b7f9e;
  --line: #e8e4de;
  --brand: #5c2d9e;
  --brand-dark: #311f49;
  --brand-soft: #f1eafb;
  --accent: #fe601c;
  --accent-soft: #fff1e8;
  --ok: #17a06b;
  --ok-soft: #e3f6ee;
  --warn: #d97706;
  --warn-soft: #fdf1e2;
  --bad: #d64545;
  --bad-soft: #fbeaea;
  --purple: #9b7bff;
  --purple-soft: #f0ebff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(25, 5, 50, .08);
  --shadow-lg: 0 8px 24px rgba(25, 5, 50, .10);
  --sidebar-w: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", "Arial", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
}
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #190532 0%, #311f49 45%, #5c2d9e 100%);
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 40px; width: 100%; max-width: 420px;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
}
.logo-mark.small { width: 30px; height: 30px; font-size: 16px; }
.logo-word { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.logo-word small { color: var(--muted); font-weight: 600; font-size: 12px; }
.login-card h1 { margin-bottom: 6px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-weight: 400; width: 100%;
}
.login-card input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

/* ---------- Layout ---------- */
#main-app { display: flex; min-height: 100vh; }
#sidebar {
  width: var(--sidebar-w); background: #311f49; color: #d9cbf0; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; }
.sidebar-logo .logo-word { color: #fff; font-size: 18px; }
#nav { flex: 1; overflow-y: auto; padding: 4px 10px 18px; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #d9cbf0; font-size: 13.5px; margin-bottom: 2px; font-weight: 500;
}
#nav a .ico { width: 18px; text-align: center; font-size: 14px; }
#nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
#nav a.active { background: var(--accent); color: #fff; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.09); }
.user-chip { font-size: 12px; margin-bottom: 8px; color: #b9a3d9; }
#content { flex: 1; padding: 0 28px 40px; min-width: 0; }
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 16px; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
#topbar-actions { display: flex; gap: 10px; }

/* ---------- Cards & Grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card h2 { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.5px; }
.kpi .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.kpi .delta { font-size: 12px; font-weight: 700; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: #cfd8e6; background: #f8fafd; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #e04e0a; border-color: #e04e0a; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.2); color: #d9cbf0; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; background: #fafbfe; }
tr:hover td { background: #f8fafd; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--brand-soft); color: var(--brand); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.grey { background: #eef1f6; color: var(--ink-soft); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px; font-weight: 400; color: var(--ink); background: #fff; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field textarea { min-height: 90px; resize: vertical; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  padding: 9px 14px; border: none; background: none; font-size: 13.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Lists / Todo ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 13.5px; }
.list-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Alert ---------- */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- Steps ---------- */
.steps { display: flex; gap: 0; margin: 14px 0 20px; flex-wrap: wrap; }
.step { flex: 1; min-width: 140px; padding: 14px; border: 1px solid var(--line); background: #fff; position: relative; }
.step:first-child { border-radius: 10px 0 0 10px; }
.step:last-child { border-radius: 0 10px 10px 0; }
.step .num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-bottom: 8px;
}
.step .s-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.step .s-desc { font-size: 12px; color: var(--ink-soft); }
@media (max-width: 900px) { .step { min-width: 100%; border-radius: 10px !important; margin-bottom: 8px; } }

/* ---------- Charts (Canvas) ---------- */
.chart-box { position: relative; width: 100%; }
canvas { display: block; width: 100%; }

/* ---------- Map ---------- */
.map-box {
  height: 340px; border-radius: var(--radius); border: 1px solid var(--line);
  background:
    linear-gradient(0deg, rgba(47,109,246,.04) 1px, transparent 1px) 0 0/40px 40px,
    linear-gradient(90deg, rgba(47,109,246,.04) 1px, transparent 1px) 0 0/40px 40px,
    #eef3fb;
  position: relative; overflow: hidden;
}
.map-dot {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(47,109,246,.3);
  transform: translate(-50%, -50%); cursor: pointer;
}
.map-dot:hover { background: var(--purple); }
.map-label {
  position: absolute; transform: translate(-50%, -140%); background: #0f1e3d; color: #fff;
  font-size: 11px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; opacity: 0; transition: opacity .15s;
  pointer-events: none;
}
.map-dot:hover + .map-label { opacity: 1; }

/* ---------- Chat ---------- */
.chat-log { max-height: 420px; overflow-y: auto; padding: 4px 0; }
.chat-msg { display: flex; gap: 10px; margin-bottom: 14px; }
.chat-msg .avatar {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.chat-msg.user .avatar { background: var(--ink); color: #fff; }
.chat-msg .bubble { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; flex: 1; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg.user .bubble { background: var(--brand-soft); border-color: #d5e4fd; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input input { flex: 1; }

/* ---------- Toast ---------- */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f1e3d; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 13px; min-width: 240px; animation: slide-in .2s ease;
}
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 30, 61, .45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 24px; width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px;
  text-align: center; color: var(--muted); cursor: pointer; transition: all .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- Misc ---------- */
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.pill-group { display: flex; gap: 6px; flex-wrap: wrap; }
.stat-bar { height: 8px; border-radius: 99px; background: #eef1f6; overflow: hidden; }
.stat-bar > div { height: 100%; border-radius: 99px; background: var(--brand); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .big { font-size: 34px; margin-bottom: 8px; }
