/* css/global.css */
:root {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-600: #4f46e5;
  --primary-50: #eef2ff;
  --success: #10b981;
  --success-50: #ecfdf5;
  --warning: #f59e0b;
  --danger: #f43f5e;
  --danger-50: #fff1f2;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow: 0 4px 16px rgba(15,23,42,0.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,0.1);
  --radius: 14px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
label.inline { display: flex; align-items: center; gap: 8px; color: var(--text); }
label input[type="checkbox"] { width: auto; }
label input, label select { margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; transition: all .15s;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--primary-50); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-ghost.btn-danger { background: transparent; color: var(--danger); }
.btn-ghost.btn-danger:hover { background: var(--danger-50); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.page { padding: 24px; max-width: 1200px; margin: 0 auto; }
.page h1 { font-size: 28px; margin-bottom: 4px; }
.page .muted { color: var(--text-muted); margin-bottom: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section { margin-bottom: 32px; }
.section h2 { font-size: 18px; margin-bottom: 12px; }

.search {
  width: 100%; margin-bottom: 16px;
  padding: 12px 16px; font-size: 15px;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.list-title { font-weight: 600; }
.list-sub { font-size: 13px; color: var(--text-muted); }
.list-actions { display: flex; gap: 4px; }

.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: 14px;
}

.loader {
  text-align: center; padding: 60px; color: var(--text-muted);
}

/* Card grid */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all .15s;
}
.stat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
  width: calc(100% - 32px);
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-content h2 { margin-bottom: 20px; }
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px;
}

/* Toast */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  opacity: 0; transform: translateX(20px);
  transition: all .25s;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--primary); }

.kv {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 14px;
  border-bottom: 1px dashed var(--border);
}
.kv span { color: var(--text-muted); }

/* Live grid */
.live-grid {
  display: grid; gap: 12px; margin-top: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.live-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.live-name { font-weight: 600; margin-bottom: 6px; }
.live-status {
  font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 12px;
  display: inline-block;
}
.live-status.active { background: var(--success-50); color: var(--success); }
.live-status.free { background: var(--primary-50); color: var(--primary); }
.live-status.off { background: #f1f5f9; color: var(--text-muted); }

.locator-card {
  padding: 16px; background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}