/* ── AUTH OVERLAY ─────────────────────────────────────── */
#auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #0f1f3d 0%, #0f1117 70%);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}

#auth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

#auth-logo {
  text-align: center;
}

.auth-logo-icon {
  font-size: 40px;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 20px rgba(59,130,246,0.6));
}

#auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

#auth-logo p {
  font-size: 13px;
  color: #8b95a9;
}

#clerk-sign-in {
  width: 100%;
}

/* ── USER EMAIL in toolbar ────────────────────────────── */
#user-email {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #0f1117;
  --bg-surface:   #161b27;
  --bg-raised:    #1e2535;
  --bg-hover:     #252d40;
  --border:       #2a3347;
  --border-light: #323d54;

  --text-primary:   #f1f5f9;
  --text-secondary: #8b95a9;
  --text-muted:     #4e5a6e;

  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim:   #1e3a5f;

  --green:        #22c55e;
  --green-dim:    #14532d;
  --red:          #ef4444;
  --red-dim:      #450a0a;
  --purple:       #a855f7;
  --purple-dim:   #3b0764;
  --amber:        #f59e0b;

  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ── TOOLBAR ─────────────────────────────────────────── */
#toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  min-height: 48px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px 8px 0;
  margin-right: 2px;
  border-right: 1px solid var(--border);
}
.tool-group:last-child { border-right: none; margin-right: 0; }

.tool-group label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-right: 2px;
  white-space: nowrap;
}

/* ── BUTTONS ──────────────────────────────────────────── */
button {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  line-height: 1.4;
}
button:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: #fff;
}
button.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
button.success {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── SELECTS & INPUTS ─────────────────────────────────── */
select, input[type="number"], input[type="text"] {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font);
  transition: border-color 0.12s;
  outline: none;
}
select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
select option { background: var(--bg-raised); }

/* ── SCALE STATUS ──────────────────────────────────────── */
#scale-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.3);
  white-space: nowrap;
}
#scale-status.unset {
  color: var(--text-muted);
  background: var(--bg-raised);
  border-color: var(--border);
}

/* ── MODE INDICATOR ───────────────────────────────────── */
#mode-indicator {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
#mode-indicator.active {
  background: rgba(59,130,246,0.12);
  color: var(--accent);
  border-color: rgba(59,130,246,0.4);
}

/* ── MAIN LAYOUT ──────────────────────────────────────── */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── CANVAS AREA ──────────────────────────────────────── */
#canvas-container {
  flex: 1;
  overflow: hidden;
  background: #090c12;
  position: relative;
}

#konva-container {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ── SIDEBAR ──────────────────────────────────────────── */
#sidebar {
  width: 300px;
  min-width: 260px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

#drop-table-wrapper {
  flex: 1;
  overflow-y: auto;
}

/* ── TABLE ────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
thead th {
  background: var(--bg-base);
  color: var(--text-muted);
  padding: 7px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:hover { background: var(--bg-raised); }
tbody tr.highlighted {
  background: var(--accent-dim);
  border-bottom-color: rgba(59,130,246,0.2);
}
tbody td {
  padding: 7px 8px;
  color: var(--text-primary);
  vertical-align: middle;
}

.del-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
}
.del-btn:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* ── CABLE BADGES ─────────────────────────────────────── */
.cat6-badge {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.cat6a-badge {
  background: var(--purple-dim);
  color: var(--purple);
  border: 1px solid rgba(168,85,247,0.3);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ── TOTALS ───────────────────────────────────────────── */
#totals {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  background: var(--bg-base);
}
#totals .total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
}
#totals .total-row span:first-child { color: var(--text-secondary); }
#totals .total-row span:last-child  { font-weight: 700; color: var(--green); }
#totals .total-row.drops span:last-child { color: var(--accent); }

/* ── EXPORT BUTTON ────────────────────────────────────── */
#export-btn {
  margin: 12px;
  padding: 9px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-md);
  letter-spacing: 0.3px;
  transition: background 0.15s, transform 0.1s;
}
#export-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
}

/* ── EMPTY STATE ──────────────────────────────────────── */
#empty-state {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 2;
}

/* ── MODAL ────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#modal-overlay.visible { display: flex; }

#modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.5);
}
#modal h3 {
  margin-bottom: 18px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}
#modal .field { margin-bottom: 14px; }
#modal .field label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
}
#modal .field input,
#modal .field select { width: 100%; }

#modal .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}
#modal .actions button { padding: 7px 18px; }
#modal .cancel-btn {
  background: var(--bg-raised);
  border-color: var(--border-light);
  color: var(--text-secondary);
}
#modal .cancel-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

/* ── CONTEXT MENU ─────────────────────────────────────── */
#context-menu {
  display: none;
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  z-index: 2000;
  min-width: 150px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
}
#context-menu.visible { display: block; }
#context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  padding: 9px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
#context-menu button:hover { background: var(--bg-raised); border-color: transparent; }
#context-menu button.danger { color: var(--red); }
#context-menu button.danger:hover { background: var(--red-dim); }

/* ── SCROLLBAR ────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
