:root {
  --bg:          #ffffff;
  --bg-2:        #f8fafc;
  --bg-3:        #f1f5f9;
  --border:      #e2e8f0;
  --border-2:    #cbd5e1;
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --primary:     #185fa5;
  --primary-l:   #e6f1fb;
  --success:     #0f6e56;
  --success-l:   #e1f5ee;
  --danger:      #a32d2d;
  --danger-l:    #fcebeb;
  --warning:     #854f0b;
  --warning-l:   #faeeda;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 1px 3px rgba(0,0,0,.08);
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'SF Mono', 'Fira Code', 'Courier New', monospace;
  --sidebar-w:   220px;
  --sidebar-w-sm:60px;
  --header-h:    52px;
  --panel-w:     40%;
  --transition:  .18s ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: var(--font); cursor: pointer; }

input, select, textarea {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-l);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* Utilities */
.hidden   { display: none !important; }
.mono     { font-family: var(--font-mono); font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-success { background: var(--success-l); color: var(--success); }
.badge-danger  { background: var(--danger-l);  color: var(--danger);  }
.badge-warning { background: var(--warning-l); color: var(--warning); }
.badge-default { background: var(--bg-3);      color: var(--text-2);  }

/* Toast Container */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-lg);
  font-size: 13px;
  min-width: 220px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
  pointer-events: auto;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger);  }
.toast.warning { background: var(--warning); }
@keyframes toast-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; } }

/* Tooltip */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 11.5px;
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 1000;
}
[data-tip]:hover::after { opacity: 1; }
