:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --surface: #f9fafb;
  --surface-2: #f3f4f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
button, select { font: inherit; }

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.brand-title {
  font-size: 14px;
  letter-spacing: 0.14em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.header-user button {
  height: 32px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

.header-user button:hover {
  background: var(--surface-2);
}

.header-status {
  font-size: 12px;
  color: var(--muted);
  max-width: 40vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-select {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-label {
  font-size: 12px;
  color: var(--muted);
}

#lang {
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.app-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

body.is-unauth .app-body {
  grid-template-columns: 1fr;
}

body.is-unauth .sidebar {
  display: none;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 12px;
}

.sidebar-title {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 8px 10px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.is-active {
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.nav-icon {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  flex: 0 0 auto;
}

.nav-label {
  font-size: 14px;
}

.content {
  padding: 18px;
}

.content-inner {
  max-width: 1100px;
}

.page-title {
  font-size: 20px;
  margin: 4px 0 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 14px;
}

.card-title {
  font-size: 14px;
  margin: 0 0 6px;
}

.card-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* Dashboard helpers */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.btn:hover {
  background: var(--surface-2);
}

.btn-primary {
  background: #a63232;
  border-color: #a63232;
  color: #fff;
}

.btn-primary:hover {
  background: #902b2b;
}

.btn-ghost {
  background: var(--bg);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.metric {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.kv {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.kv-k {
  color: var(--muted);
}

.kv-v {
  font-weight: 650;
  text-align: right;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
  margin-left: 8px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.placeholder {
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

.auth-wrap {
  max-width: 420px;
  margin: 56px auto;
}

.auth-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-title {
  font-size: 18px;
  margin: 0 0 6px;
}

.auth-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.auth-field label {
  font-size: 12px;
  color: var(--muted);
}

.auth-field input {
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.auth-actions button {
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

.auth-actions button:hover {
  background: var(--surface-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  max-width: 92vw;
}

@media (max-width: 980px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .grid { grid-template-columns: 1fr; }
  .header-status { display: none; }
}
/* --------------------------------------------------------------------------
   Auth screen (login)
   -------------------------------------------------------------------------- */

body.is-unauth .app-header {
  display: none;
}

body.is-unauth .app-body {
  padding: 0;
  grid-template-columns: 1fr;
}

body.is-unauth .app-sidebar {
  display: none;
}

body.is-unauth .app-main {
  padding: 0;
}

/* Container used by the current SPA auth/signup/onboarding screens */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.02);
}

.auth-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.45);
}

.auth-center {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e5e5e5;
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-direction: column;
  margin-bottom: 12px;
}

.auth-logo {
  width: 110px;
  height: auto;
  display: block;
  margin: 0 auto 12px;
}

.auth-title {
  text-align: center;
  font-size: 14px;
  color: #666;
  margin: 0;
}

.auth-subtitle {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 12px;
}

.auth-tab {
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 999px;
  height: 38px;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  color: #666;
}

.auth-tab:hover {
  background: #f7f7f7;
}

.auth-tab.is-active {
  background: #a63232;
  border-color: #a63232;
  color: #fff;
}

.auth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-help {
  margin-top: 6px;
  font-size: 12px;
  color: #666;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(166, 50, 50, 0.08);
  border: 1px solid rgba(166, 50, 50, 0.18);
  color: #7b1e1e;
  font-size: 12px;
  margin-bottom: 10px;
}

.pill a {
  color: inherit;
  text-decoration: underline;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-label {
  font-size: 12px;
  color: #555;
}

.auth-input {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.auth-input:focus {
  border-color: #a63232;
  box-shadow: 0 0 0 3px rgba(166, 50, 50, 0.12);
}

.auth-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.auth-link {
  font-size: 12px;
  color: #0b6aa8;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-btn {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #a63232;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.auth-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-error {
  margin-top: 10px;
  background: rgba(166, 50, 50, 0.1);
  border: 1px solid rgba(166, 50, 50, 0.25);
  color: #7b1e1e;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}

@media (max-width: 520px) {
  .auth-card {
    padding: 18px 16px 14px;
    border-radius: 16px;
  }
  .auth-logo {
    width: 92px;
  }
  .auth-row {
    grid-template-columns: 1fr;
  }
}

/* Auth overrides for existing shell classes */
body.is-unauth .sidebar {
  display: none;
}
body.is-unauth .content {
  padding: 0;
}

body.is-unauth .content-inner {
  max-width: none;
}


/* --------------------------------------------------------------------------
   Lists (Step2-B)
   -------------------------------------------------------------------------- */

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.list-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.list-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pager-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pager-meta {
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
}

.list-input,
.list-select {
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
}

.table-wrap {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 12px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

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

.empty-state {
  padding: 8px 2px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
}

.badge-ok {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.20);
  color: #065f46;
}

.badge-warn {
  background: rgba(166, 50, 50, 0.10);
  border-color: rgba(166, 50, 50, 0.25);
  color: #7b1e1e;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field label {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .list-right { justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
}
