:root {
  --bg: #F5F3EE;
  --surface: #FAFAF7;
  --surface-2: #EEECEA;
  --border: #DDD9D3;
  --text: #1A1A2E;
  --text-muted: #6B6B7B;
  --primary: #003F74;
  --primary-hover: #002D56;
  --primary-soft: #E0EAF4;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --success: #15803D;
  --warning: #B45309;
  --navy-chrome: #002347;
  --shadow-sm: 0 1px 3px rgba(0, 35, 71, 0.07);
  --shadow-md: 0 4px 16px rgba(0, 35, 71, 0.10);
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--navy-chrome);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
}
.login-card .subtitle {
  margin: 0 0 28px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Forms ---------- */
.field {
  display: block;
  margin-bottom: 14px;
}
.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 13px;
}
.field .hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 63, 116, 0.12);
}
textarea {
  resize: vertical;
  min-height: 70px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ---------- App shell ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--navy-chrome);
  border-bottom: none;
}
.topbar .brand {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  letter-spacing: 0.01em;
}
.brand-logo {
  height: 36px;
  width: auto;
}
.login-logo {
  display: block;
  height: 80px;
  width: auto;
  margin: 0 auto 12px;
}
.topbar .user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}
.topbar .user .btn {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  color: #ffffff;
  font-size: 12.5px;
}
.topbar .user .btn:hover {
  background: rgba(255,255,255,0.2);
}

.tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--primary);
  border-bottom: none;
}
.tab {
  padding: 11px 18px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.01em;
}
.tab:hover { color: rgba(255,255,255,0.9); }
.tab.active {
  color: #ffffff;
  border-bottom-color: #ffffff;
}

.tab-panel {
  display: none;
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.tab-panel.active { display: block; }

/* ---------- Filters bar ---------- */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.filters .actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead {
  background: var(--surface-2);
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th .sort-indicator {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.5;
}
tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-open { background: #fef3c7; color: #92400e; }
.badge-progress { background: #dbeafe; color: #1e40af; }
.badge-resolved { background: #dcfce7; color: #166534; }
.badge-closed { background: #e5e7eb; color: #374151; }

/* ---------- New ticket form ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 900px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Screenshot drop zone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.dropzone.has-image {
  padding: 12px;
  border-style: solid;
}
.dropzone img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
}
.dropzone .remove-img {
  margin-top: 8px;
}

/* Inline contact add */
.requester-row {
  display: flex;
  gap: 8px;
}
.requester-row select { flex: 1; }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.modal-footer .right { display: flex; gap: 8px; }

.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}
.close-btn:hover { color: var(--text); }

/* Image lightbox */
.lightbox-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.lightbox-backdrop.show { display: flex; }
.lightbox-backdrop img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: 4px;
}

/* ---------- Report ---------- */
.report-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  flex: 1;
}
.report-filters .field {
  margin: 0;
  min-width: 150px;
  flex: 1;
}
.report-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.card .value {
  font-size: 24px;
  font-weight: 700;
}

.report-section {
  margin-bottom: 20px;
}
.report-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ---------- Toast / messages ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 300;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.error-message {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }

/* Multi-select checkboxes */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 36px;
}
.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.checkbox-group label:hover { background: var(--surface-2); }
.checkbox-group input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ---------- Settings tab ---------- */
.settings-section {
  max-width: 640px;
}
.settings-heading {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  color: var(--primary);
}
.settings-desc {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}
.domain-add-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.domain-add-form .field {
  margin: 0;
  flex: 1;
  min-width: 160px;
}

/* ---------- Client badge ---------- */
.badge-client { background: #ede9fe; color: #5b21b6; }

/* ---------- Client portal ---------- */
.client-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background: var(--navy-chrome);
}

.client-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.client-card-header {
  background: var(--primary);
  padding: 32px 36px 24px;
  text-align: center;
}
.client-card-header .login-logo {
  margin-bottom: 16px;
}
.client-card-header h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
}
.client-card-header .subtitle {
  margin: 0;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
}

.client-step {
  padding: 28px 36px 32px;
}

/* OTP step */
.otp-info {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}
.otp-back {
  margin: 12px 0 0;
  font-size: 13px;
  text-align: center;
}

/* Verified email strip inside step 3 */
.verified-email-strip {
  margin: 0 0 20px;
  padding: 8px 12px;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--success);
}

/* Success state */
.success-state {
  padding: 56px 36px;
  text-align: center;
}
.success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success);
  color: #ffffff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.success-state h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--text);
}
.success-state p {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Submitted-by info strip in edit modal */
.submitted-by-strip {
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12.5px;
  color: #5b21b6;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar, .tabs, .tab-panel { padding-left: 12px; padding-right: 12px; }
  .client-card form,
  .client-card-header,
  .success-state { padding-left: 20px; padding-right: 20px; }
}
