:root {
  --color-bg: #f7f7fb;
  --color-surface: #ffffff;
  --color-border: #e2e2ea;
  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --color-primary: #4338ca;
  --color-primary-hover: #3730a3;
  --color-danger: #b91c1c;
  --color-success: #15803d;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

/* Auth page */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
}
.subtitle {
  margin: 0 0 24px;
  color: var(--color-text-muted);
  font-size: 14px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.stack label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

input,
select,
textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-bg);
}

.error-text {
  color: var(--color-danger);
  font-size: 13px;
  margin: 0;
  min-height: 1em;
}

/* Dashboard shell */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.topbar-brand {
  font-weight: 700;
  font-size: 16px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
}
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--color-border);
}
.data-table tr:last-child td {
  border-bottom: none;
}
.empty {
  color: var(--color-text-muted);
  text-align: center;
  padding: 24px !important;
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--color-primary);
  text-transform: capitalize;
}
.badge-inactive,
.badge-archived,
.badge-cancelled {
  background: #f3f4f6;
  color: var(--color-text-muted);
}
.badge-draft {
  background: #fef3c7;
  color: #92400e;
}

.banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.hidden {
  display: none !important;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
}
.modal-header .btn-ghost {
  font-size: 18px;
  line-height: 1;
  padding: 2px 8px;
}
.modal fieldset {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 14px;
  margin: 0;
}
.modal legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 0 4px;
}
.modal fieldset + fieldset {
  margin-top: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.result-box {
  margin: 0;
  font-size: 13px;
}
.result-box:empty {
  display: none;
}
.result-error {
  color: var(--color-danger);
}
.result-success {
  color: var(--color-success);
}
.result-success code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  word-break: break-all;
}
