:root {
  --green: #0b6e3a;
  --green-dark: #085229;
  --blue: #1f4e8c;
  --blue-dark: #163a68;
  --bg: #f4f7f6;
  --card: #ffffff;
  --border: #e1e6e4;
  --text: #1b241f;
  --text-muted: #5f6b66;
  --danger: #c62828;
  --warning: #b8860b;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 40, 30, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--blue); }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header.center-layout { position: sticky; }
.app-header .center-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 700;
  font-size: 17px;
  color: var(--green-dark);
}
.app-header .brand { display: flex; align-items: center; gap: 12px; }
.app-header img.logo { height: 36px; width: auto; object-fit: contain; }
.app-header .brand-title { font-weight: 700; font-size: 17px; color: var(--green-dark); }
.app-header .right { display: flex; align-items: center; gap: 14px; }
.header-actions { display: flex; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover { background: var(--blue-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f0f2f1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Layout ---------- */
.page-container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Mobile header/layout fixes ---------- */
@media (max-width: 640px) {
  .app-header { padding: 10px 16px; flex-wrap: wrap; row-gap: 6px; }
  .app-header .center-title { display: none; }
  .app-header img.logo { height: 28px; }
  .app-header .right { gap: 8px; }
  .app-header .right .muted { display: none; }
  .top-right-buttons { position: static; justify-content: center; margin: 14px 20px 0; }
  .hero { padding: 30px 16px 20px; }
  .hero .dept-photo-wrap img { width: 220px; height: 220px; }
  .page-container { padding: 16px 14px 40px; }
  .card { padding: 16px; }
}

/* ---------- Home / Landing page ---------- */
.hero {
  text-align: center;
  padding: 60px 20px 30px;
}
.hero .dept-photo-wrap {
  display: inline-block;
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
  border: 5px solid var(--card);
  box-shadow: 0 6px 24px rgba(20, 40, 30, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero .dept-photo-wrap:hover { transform: translateY(-3px); box-shadow: 0 10px 32px rgba(20, 40, 30, 0.2); }
.hero .dept-photo-wrap img { display: block; width: 320px; height: 320px; object-fit: cover; }
.hero h1 { margin-top: 22px; font-size: 30px; color: var(--green-dark); }
.hero p.hint { color: var(--text-muted); font-size: 14px; }
.top-right-buttons {
  position: fixed;
  top: 78px;
  right: 24px;
  display: flex;
  gap: 10px;
  z-index: 10;
}

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.field { margin-bottom: 16px; }
.field .error-text { color: var(--danger); font-size: 12px; margin-top: 4px; }
textarea { min-height: 100px; resize: vertical; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-NEW { background: #e8eef7; color: var(--blue-dark); }
.badge-ACKNOWLEDGE { background: #fff3cd; color: #8a6d00; }
.badge-IN_PROGRESS { background: #dbeeff; color: #0d5aa7; }
.badge-PENDING { background: #ffe4d6; color: #b3400a; }
.badge-RESOLVED { background: #dff5e6; color: var(--green-dark); }
.badge-sev-Low { background: #e7f4ea; color: #2e7d32; }
.badge-sev-Medium { background: #fff3cd; color: #8a6d00; }
.badge-sev-High { background: #fde0e0; color: var(--danger); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  padding: 12px 18px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab-btn.active { color: var(--green-dark); border-bottom-color: var(--green); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { background: #f6f9f7; color: var(--text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafcfb; }
.table-wrap { overflow-x: auto; }
.clickable-row { cursor: pointer; }

/* ---------- Toast ---------- */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  padding: 12px 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  min-width: 220px;
  animation: slideIn 0.2s ease;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--blue); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 20, 15, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); max-width: 720px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h2 { margin: 0; font-size: 20px; color: var(--green-dark); }
.close-x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.spinner {
  border: 3px solid #eee; border-top: 3px solid var(--green); border-radius: 50%;
  width: 22px; height: 22px; animation: spin 0.7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.kpi { text-align: center; }
.kpi .value { font-size: 30px; font-weight: 800; color: var(--green-dark); }
.kpi .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.filters-bar .field { margin-bottom: 0; min-width: 150px; }
.timeline { border-left: 2px solid var(--border); margin-left: 6px; padding-left: 18px; }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -23px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.timeline-item .ts { font-size: 12px; color: var(--text-muted); }
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 16px; align-items: center; }
