/* Same look as the Bimal Auto dashboard: slate greys, Inter, white top bar and tabs, white cards. */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;

  --text: #0f172a;
  --text-secondary: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --green: #10b981;
  --green-light: #d1fae5;
  --green-text: #065f46;

  --red: #ef4444;
  --red-light: #fee2e2;
  --red-text: #991b1b;

  --yellow: #f59e0b;
  --yellow-light: #fef3c7;
  --yellow-text: #92400e;

  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --transition: all 0.2s ease-in-out;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container { display: flex; flex-direction: column; min-height: 100vh; }

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.brand-mark { width: 32px; height: 32px; display: block; flex: none; }
.auth-brand .brand-mark { width: 40px; height: 40px; }
.brand-name { font-weight: 700; font-size: 1rem; }
.brand-title {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 1.1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  overflow-x: auto;
}
.tab {
  padding: 0.9rem 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  transition: var(--transition);
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-badge.orders { background: #2563eb; }
.tab-badge {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.ui-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.8;
  vertical-align: -0.16em;
}

/* Content */
.tab-content {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--surface-hover);
}
.card-heading { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}
.btn-outline { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: #cbd5e1; background: var(--surface-hover); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-primary { background: var(--primary); border: 1px solid var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--surface); border: 1px solid #fecaca; color: var(--red-text); }
.btn-danger:hover { background: var(--red-light); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn:disabled .ui-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-hover);
  color: var(--text-secondary);
  white-space: nowrap;
}
.status-badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}
.status-badge[data-status="ok"] { background: var(--green-light); color: var(--green-text); }
.status-badge[data-status="warning"] { background: var(--yellow-light); color: var(--yellow-text); }
.status-badge[data-status="down"] { background: var(--red-light); color: var(--red-text); }

.message { margin: 0 0 1.25rem; font-size: 0.95rem; }
.message[data-status="down"] { color: var(--red-text); font-weight: 500; }
.message[data-status="warning"] { color: var(--yellow-text); font-weight: 500; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-sub { margin-top: 0.15rem; font-size: 0.8rem; color: var(--text-secondary); white-space: pre-line; }

/* Table */
.table-card { padding: 0; overflow: hidden; }
.table-card .card-header { padding: 1rem 1.5rem 0.75rem; margin-bottom: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.75rem 1.5rem; text-align: left; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-hover); }
td.when { color: var(--text-secondary); white-space: nowrap; }
.empty-row { text-align: center; color: var(--text-secondary); padding: 2rem; }

@media (max-width: 720px) {
  .topbar, .tabs { padding-left: 1rem; padding-right: 1rem; }
  .tab-content { padding: 1rem; }
  .card { padding: 1rem; }
  .table-card { padding: 0; }
  .card-header { align-items: flex-start; }
  th, td { padding: 0.65rem 1rem; }
  table { min-width: 560px; }
}

/* Top bar: who is signed in */
a.brand { text-decoration: none; color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 0.6rem; }
.user-name { font-weight: 600; font-size: 0.92rem; }
.role-chip { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.2rem 0.55rem; border-radius: 999px;
  background: var(--primary-light); color: var(--primary); }
.role-chip.role-owner { background: #fef3c7; color: #92400e; }
.role-chip.role-staff { background: #f1f5f9; color: #475569; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 1rem; }
  .user-menu { gap: 0.4rem; }
  .user-name { display: none; }
  .user-menu .btn { padding: 0.3rem 0.55rem; font-size: 0.78rem; }
}

/* Sign in, first owner, change password */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem 1.75rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06); }
.auth-brand { display: flex; align-items: center; gap: 0.6rem; justify-content: center; margin-bottom: 1.4rem; font-weight: 700; font-size: 1.1rem; }
.auth-card h1 { font-size: 1.35rem; margin: 0 0 0.35rem; text-align: center; }
.auth-card .auth-intro { margin: 0 0 1.4rem; color: var(--text-secondary); text-align: center; font-size: 0.92rem; line-height: 1.5; }
.field { display: grid; gap: 0.35rem; margin-bottom: 1rem; }
.field label { font-size: 0.88rem; font-weight: 600; }
.field input, .field select { font: inherit; font-size: 1rem; padding: 0.7rem 0.85rem; border: 1px solid var(--border); border-radius: 10px; background: #fff;
  outline: none; width: 100%; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.field small { color: var(--text-secondary); font-size: 0.8rem; }
.auth-error { background: var(--red-light); color: var(--red-text); border-radius: 10px; padding: 0.65rem 0.85rem; font-size: 0.88rem; margin-bottom: 1rem; }
.btn-block { width: 100%; justify-content: center; padding: 0.8rem; font-size: 1rem; }
.auth-show { display: flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; margin: -0.3rem 0 1.1rem; color: var(--text-secondary); cursor: pointer; }
.auth-links { text-align: center; margin-top: 1rem; font-size: 0.88rem; }
.auth-links a { color: var(--primary); text-decoration: none; }
.no-access { max-width: 520px; margin: 3rem auto; text-align: center; color: var(--text-secondary); }
.no-access b { display: block; font-size: 1.2rem; color: var(--text); margin-bottom: 0.4rem; }
a.btn { text-decoration: none; }
