*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #d8dee9;
  --text: #1a2332;
  --muted: #5c6b7a;
  --primary: #1d5fbf;
  --primary-hover: #174d9c;
  --danger: #c0392b;
  --success: #1e7a46;
  --shadow: 0 8px 24px rgba(20, 35, 60, 0.08);
  --radius: 10px;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  background: #e8edf3;
  color: var(--text);
  transition: background 0.15s;
}

.btn:hover {
  background: #dde4ec;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger {
  background: #fdecea;
  color: var(--danger);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.input,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.input:focus,
.select:focus {
  outline: 2px solid rgba(29, 95, 191, 0.25);
  border-color: var(--primary);
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-row {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  margin-top: 8px;
}

.success {
  color: var(--success);
  margin-top: 8px;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

/* App shell */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-btn {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}

.nav-btn.active,
.nav-btn:hover {
  background: #eef3fa;
  color: var(--primary);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar .field {
  min-width: 140px;
}

.page-title {
  margin: 0 0 16px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 70vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
}

th,
td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
}

th {
  background: #eef3fa;
  position: sticky;
  top: 0;
  z-index: 2;
}

th.sticky-col,
td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
}

th.sticky-col-2,
td.sticky-col-2 {
  position: sticky;
  left: 72px;
  z-index: 3;
  background: #fff;
}

th.sticky-col,
th.sticky-col-2 {
  background: #eef3fa;
  z-index: 4;
}

td.route-cell {
  font-weight: 600;
  background: #fafbfc;
}

.qty-input {
  width: 64px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

.qty-input:focus {
  outline: 2px solid rgba(29, 95, 191, 0.25);
  border-color: var(--primary);
}

.total-cell {
  font-weight: 600;
  background: #f7fafc;
}

.hidden {
  display: none !important;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #eef3fa;
  color: var(--primary);
}

.badge-inactive {
  background: #fdecea;
  color: var(--danger);
}

@media (max-width: 768px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .user-bar {
    justify-content: space-between;
  }
}
