/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e8eaed;
  --border-light: #f1f3f5;
  --text: #1a1d23;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #059669;
  --success-light: #ecfdf5;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning-light: #fffbeb;
  --warning-text: #92400e;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --transition: 150ms ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}

.nav-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.nav-dropdown-toggle::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-left: 4px;
  vertical-align: 1px;
}

.nav-dropdown-toggle:hover,
.nav-dropdown:hover .nav-dropdown-toggle {
  color: var(--text);
  background: var(--bg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 6px; /* invisible bridge so hover isn't lost */
  z-index: 200;
}

.nav-dropdown-menu-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  padding: 4px;
}

.nav-dropdown:hover .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}

.nav-dropdown-menu a:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.nav-user {
  color: var(--text-tertiary);
  font-size: 13px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

/* Container */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;
  width: 100%;
}

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 48px 40px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
}

.login-card h1 {
  margin-bottom: 32px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-tertiary); }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  max-width: 800px;
}

.form-card h3 {
  margin: 28px 0 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.form-card h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.form-actions {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding-top: 24px;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] { width: auto; }

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
}

.toggle-option:last-child { border-right: none; }

.toggle-option:has(input:checked) {
  background: var(--primary);
  color: #fff;
}

.toggle-option input[type="radio"] {
  display: none;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-group .checkbox-label {
  padding-top: 0;
  font-size: 13px;
  color: var(--text);
}

.checkbox-group-compact .checkbox-label { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
  line-height: 1.4;
  gap: 6px;
  position: relative;
  isolation: isolate;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow:
    0 1px 2px rgba(37,99,235,0.3),
    0 4px 12px rgba(37,99,235,0.15),
    inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover {
  box-shadow:
    0 2px 4px rgba(37,99,235,0.35),
    0 8px 20px rgba(37,99,235,0.2),
    inset 0 1px 0 rgba(255,255,255,0.1);
  background: linear-gradient(135deg, #4f8ff7, #1d4ed8);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow:
    0 1px 2px rgba(5,150,105,0.3),
    0 4px 12px rgba(5,150,105,0.12),
    inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-success:hover {
  box-shadow:
    0 2px 4px rgba(5,150,105,0.35),
    0 8px 20px rgba(5,150,105,0.18),
    inset 0 1px 0 rgba(255,255,255,0.1);
  background: linear-gradient(135deg, #34d399, #047857);
}

.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  box-shadow:
    0 1px 2px rgba(239,68,68,0.25),
    0 4px 12px rgba(239,68,68,0.1),
    inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-danger:hover {
  box-shadow:
    0 2px 4px rgba(239,68,68,0.3),
    0 8px 20px rgba(239,68,68,0.15),
    inset 0 1px 0 rgba(255,255,255,0.1);
  background: linear-gradient(135deg, #fca5a5, #dc2626);
}

.btn-outline {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #c9cdd3;
  box-shadow: var(--shadow);
}

.btn-block { width: 100%; }
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
  font-weight: 500;
}
.btn-sm:hover { transform: translateY(0); }

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

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin: 4px 0;
  letter-spacing: -1px;
}

.card-search {
  border-top: none;
  position: relative;
  overflow: hidden;
}

.card-search::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
}

.card-search h2 {
  font-size: 16px;
  margin-bottom: 2px;
  font-weight: 700;
}

.card-search .text-muted { margin-bottom: 16px; }

.quick-form .form-group { margin-bottom: 10px; }
.quick-form .form-group:last-of-type { margin-bottom: 14px; }

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-sm {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
}

.input-sm:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

select.input-sm { background: var(--surface); }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.table th, .table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: #fafbfc; }

.table-compact th, .table-compact td {
  padding: 7px 12px;
  font-size: 13px;
}

.table-responsive { overflow-x: auto; }

.row-error { background: var(--danger-light); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-success {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #047857;
  box-shadow: 0 1px 2px rgba(5,150,105,0.08);
}
.badge-warning {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  color: var(--warning-text);
  box-shadow: 0 1px 2px rgba(146,64,14,0.06);
}
.badge-error {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  color: #b91c1c;
  box-shadow: 0 1px 2px rgba(239,68,68,0.08);
}
.badge-info {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1e40af;
  box-shadow: 0 1px 2px rgba(37,99,235,0.06);
}

.badge-clickable {
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.badge-clickable:hover { opacity: 0.8; transform: scale(1.04); }

.price-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #047857;
  box-shadow: 0 1px 2px rgba(5,150,105,0.1);
  white-space: nowrap;
}

.price-tag-lg {
  padding: 8px 16px;
  font-size: 20px;
  border-radius: 8px;
}

.price-tag-good {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #047857;
}

.price-tag-bad {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  color: #b91c1c;
}

/* Detail page params box */
.params-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.params-box .param {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.params-box .param-label {
  color: var(--text-tertiary);
  font-weight: 500;
}

.params-box .param-value {
  color: var(--text);
  font-weight: 600;
}

.params-box .param-divider {
  color: var(--border);
}

.params-box .param-url {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
  font-weight: 400;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.detail-header h1 { margin-bottom: 4px; }

.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

/* Headings */
h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  margin-top: 32px;
  color: var(--text);
}

h2:first-child { margin-top: 0; }

/* Helpers */
.text-muted { color: var(--text-tertiary); }
.text-small { font-size: 13px; }
.text-success { color: var(--success); }

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline { display: inline; }
.inline-form { display: inline; }

.actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 12px;
  margin-top: auto;
  border-top: 1px solid var(--border-light);
}

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 20px 16px; }
  .navbar { padding: 0 16px; }
  .nav-links { gap: 2px; }
  .nav-links a { padding: 6px 8px; font-size: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .actions { flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
