:root {
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --border: #dde3ea;
  --primary: #0d5c4b;
  --primary-hover: #094a3d;
  --accent: #c9a227;
  --danger: #b42318;
  --success: #067647;
  --new: #1d4ed8;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(26, 35, 50, 0.08);
  font-family: "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  color: var(--primary);
}

.login-card .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Layout */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.header-meta {
  font-size: 0.85rem;
  opacity: 0.9;
}

.badge-new {
  background: var(--accent);
  color: #1a2332;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  margin-left: 0.35rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.connectivity-bar {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  text-align: center;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
}

.connectivity-bar.online-pending {
  background: #dbeafe;
  color: #1e40af;
  border-bottom-color: #93c5fd;
}

.sync-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #dbeafe;
  color: #1e40af;
  vertical-align: middle;
}

.sync-tag.offline-tag {
  background: #fef3c7;
  color: #92400e;
}

.build-id {
  display: block;
  font-size: 0.7rem;
  opacity: 0.75;
  margin-top: 0.15rem;
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 0.85rem;
  font-family: inherit;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: #e8ecef;
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}

tr:hover td {
  background: #f8fafb;
}

.row-click {
  cursor: pointer;
}

/* Status pills */
.status {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}

.status-open {
  background: #dbeafe;
  color: var(--new);
}
.status-in_progress {
  background: #fef3c7;
  color: #92400e;
}
.status-pending_info {
  background: #fff7ed;
  color: #9a3412;
}
.status-resolved {
  background: #d1fae5;
  color: #065f46;
}
.status-closed {
  background: #dcfce7;
  color: var(--success);
}
.status-declined {
  background: #fee2e2;
  color: var(--danger);
}

.urgent-tag {
  color: var(--danger);
  font-weight: 700;
  font-size: 0.75rem;
}

/* Detail panel */
.detail-grid {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.detail-grid dt {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
}
.detail-grid dd {
  margin: 0 0 0.5rem;
}

.messages {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.message {
  padding: 0.65rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.message-manager {
  background: #ecfdf5;
  border-left: 3px solid var(--primary);
}

.message-requester {
  background: #f1f5f9;
  border-left: 3px solid var(--muted);
}

.message-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: flex-end;
}

.filters label {
  margin-bottom: 0;
}

.filters select,
.filters input {
  margin-bottom: 0;
  width: auto;
  min-width: 140px;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--text);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.toast.success {
  background: var(--success);
}
.toast.error {
  background: var(--danger);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: -0.5rem;
  margin-bottom: 0.85rem;
}

.setup-error {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.back-link {
  color: var(--primary);
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  display: inline-block;
}

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

/* Phones & small tablets */
@media (max-width: 640px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .app-header h1 {
    font-size: 1rem;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .app-main {
    padding: 1rem 0.75rem;
  }

  .login-card {
    padding: 1.5rem 1.25rem;
  }

  .card {
    padding: 1rem;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }

  .filters select,
  .filters input {
    width: 100%;
    min-width: 0;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  table {
    font-size: 0.8rem;
  }

  th,
  td {
    padding: 0.5rem 0.35rem;
  }
}


/* Module 14 homepage footer */
.site-footer {
  margin-top: 2rem;
  padding: 1.25rem 1rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  background: #eef2f5;
}
.site-footer p {
  margin: 0.25rem 0;
}
