/* 3DSAFE Ops — design tokens */
:root {
  --bg:        #0b0c0e;
  --bg-2:      #111316;
  --bg-3:      #161a1f;
  --surface:   #1a1f25;
  --surface-2: #20262e;
  --line:      #2a3038;
  --line-2:    #353c46;
  --text:      #eef0f3;
  --muted:     #8a93a0;
  --muted-2:   #5d6571;
  --accent:    #e63946;
  --accent-2:  #b32d38;
  --ok:        #2dd4bf;
  --warn:      #f5b342;
  --bad:       #ef4444;
  --info:      #60a5fa;
  --radius:    8px;
  --radius-sm: 5px;
  --shadow:    0 10px 30px rgba(0,0,0,.4);
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:      ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

/* ===== LOGIN ===== */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 50% at 50% 0%, rgba(230,57,70,.10) 0%, rgba(0,0,0,0) 60%), var(--bg);
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-brand { font-weight: 700; font-size: 22px; letter-spacing: .5px; }
.login-brand span { color: var(--accent); margin-left: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-top: -10px; }
.login-err {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}

/* ===== APP LAYOUT ===== */
.app {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  gap: 16px;
}
.brand { font-weight: 700; font-size: 18px; padding: 4px 8px 12px; border-bottom: 1px solid var(--line); }
.brand span { color: var(--accent); margin-left: 4px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--bg-3); color: var(--text); }
.nav a.active { background: var(--surface); color: var(--text); }

.side-foot { padding-top: 12px; border-top: 1px solid var(--line); }

.main { min-width: 0; padding: 24px 30px 40px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 14px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 600; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background .12s, border .12s, transform .04s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-2); }
.btn-danger { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.4); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 5px 8px; }

/* ===== FORMS ===== */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .12s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ===== CARDS / VIEW ===== */
.view { display: flex; flex-direction: column; gap: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }

/* dashboard stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat .val { font-size: 28px; font-weight: 600; margin-top: 6px; }
.stat.bad .val { color: var(--bad); }
.stat.ok .val  { color: var(--ok); }
.stat.warn .val { color: var(--warn); }

.cols-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== TABLES ===== */
.tbl-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
table.tbl th, table.tbl td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.tbl th {
  background: var(--bg-3);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: rgba(255,255,255,0.025); }
.cell-actions { white-space: nowrap; }
.cell-actions .btn { margin-right: 4px; }

.task-done td { color: var(--muted-2); }
.task-done .title { text-decoration: line-through; text-decoration-color: var(--muted-2); }
.task-late .deadline { color: var(--bad); font-weight: 600; }

/* badges */
.b {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.b-todo     { background: rgba(96,165,250,.12); color: #93c5fd; border-color: rgba(96,165,250,.25); }
.b-doing    { background: rgba(245,179,66,.12); color: #fcd34d; border-color: rgba(245,179,66,.25); }
.b-blocked  { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.25); }
.b-done     { background: rgba(45,212,191,.10); color: #5eead4; border-color: rgba(45,212,191,.25); }

.b-low      { background: rgba(120,120,120,.10); color: #aaa; border-color: rgba(120,120,120,.25); }
.b-med      { background: rgba(96,165,250,.10); color: #93c5fd; border-color: rgba(96,165,250,.25); }
.b-high     { background: rgba(245,179,66,.12); color: #fcd34d; border-color: rgba(245,179,66,.25); }
.b-crit     { background: rgba(239,68,68,.14); color: #fca5a5; border-color: rgba(239,68,68,.35); }

.b-contact  { background: rgba(120,120,120,.12); color: #ccc; border-color: rgba(120,120,120,.25); }
.b-contacted{ background: rgba(96,165,250,.12); color: #93c5fd; border-color: rgba(96,165,250,.25); }
.b-meeting  { background: rgba(245,179,66,.12); color: #fcd34d; border-color: rgba(245,179,66,.25); }
.b-nego     { background: rgba(167,139,250,.14); color: #c4b5fd; border-color: rgba(167,139,250,.3); }
.b-won      { background: rgba(45,212,191,.14); color: #5eead4; border-color: rgba(45,212,191,.3); }
.b-lost     { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.25); }
.b-followup { background: rgba(96,165,250,.14); color: #93c5fd; border-color: rgba(96,165,250,.3); }

/* ===== TOOLS ROW (search + filter) ===== */
.tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.tools input, .tools select {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  min-width: 180px;
}
.tools input:focus, .tools select:focus { border-color: var(--accent); }

/* ===== MODAL ===== */
.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 100;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: min(640px, 95vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal-head, .modal-foot {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-foot { border-bottom: 0; border-top: 1px solid var(--line); gap: 8px; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px; overflow: auto; }
.modal-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

/* ===== TOASTS ===== */
.toasts {
  position: fixed;
  bottom: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line-2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 200px;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease-out;
}
.toast.ok    { border-left: 3px solid var(--ok); }
.toast.err   { border-left: 3px solid var(--bad); }
.toast.info  { border-left: 3px solid var(--info); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== UTIL ===== */
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 20px; text-align: center; font-style: italic; font-size: 13px; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.list-clean { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.list-clean li { padding: 8px 10px; background: var(--bg-3); border-radius: var(--radius-sm); border: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.list-clean .lh { font-weight: 500; }
.list-clean .ls { font-size: 12px; color: var(--muted); }
.dash-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 12px; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dash-item.pinned { border-left: 3px solid var(--accent); }
.dash-item .content { white-space: pre-wrap; flex: 1; word-break: break-word; }
.dash-item .acts { display: flex; gap: 4px; }

/* responsive */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: relative; height: auto;
    flex-direction: row; flex-wrap: wrap;
    padding: 12px;
  }
  .brand { border: 0; padding: 0 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 6px 10px; font-size: 12.5px; }
  .side-foot { border: 0; padding: 0; margin-left: auto; }
  .main { padding: 18px 16px 30px; }
}
