/****************************************************
 HSE PERFORMANCE DASHBOARD
 Responsive UI Stylesheet
 Version: 1.0.0
****************************************************/

:root {
  --navy: #10243a;
  --navy-light: #183650;
  --primary: #1976d2;
  --primary-light: #eaf3ff;
  --accent: #16a085;
  --background: #f4f7fb;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #758195;
  --border: #e5eaf1;
  --success: #16865b;
  --success-bg: #e8f7ef;
  --warning: #c78112;
  --warning-bg: #fff5df;
  --danger: #d74747;
  --danger-bg: #fff0f0;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(18, 38, 63, 0.045);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Arial, sans-serif;
  background: var(--background);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* LOGIN */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, #1e5277 0, transparent 36%),
    linear-gradient(135deg, #0c1e32, #183650 60%, #10243a);
}

.login-card {
  width: 100%;
  max-width: 430px;
  padding: 34px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
}

.login-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-brand h1 {
  font-size: 19px;
  font-weight: 750;
  color: var(--navy);
}

.login-brand p {
  color: var(--muted);
  font-size: 12px;
}

.login-heading {
  margin: 34px 0 24px;
}

.login-heading h2 {
  font-size: 25px;
  margin-bottom: 6px;
}

.login-heading p {
  color: var(--muted);
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#login-form label {
  font-weight: 650;
  font-size: 13px;
  margin-top: 7px;
}

#login-form input {
  width: 100%;
  height: 47px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.primary-button {
  width: 100%;
  min-height: 47px;
  border: 0;
  border-radius: 10px;
  margin-top: 15px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  transition: 0.2s;
}

.primary-button:hover {
  background: #1265b4;
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.message {
  min-height: 18px;
  font-size: 12px;
  text-align: center;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

/* APPLICATION LAYOUT */

.app-screen {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 255px;
  min-width: 255px;
  background: var(--navy);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 15px 16px;
}

.sidebar-brand {
  padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand .brand-logo {
  background: #1b85df;
  flex-shrink: 0;
}

.brand-text strong {
  display: block;
  font-size: 15px;
}

.brand-text small {
  display: block;
  color: #a8bacb;
  font-size: 10px;
  margin-top: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 5px;
  padding: 12px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
}

.user-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e5efff;
  color: var(--primary);
  font-weight: 750;
  overflow: hidden;
}

.user-info {
  min-width: 0;
}

.user-info strong,
.user-info small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-info strong {
  font-size: 12px;
}

.user-info small {
  color: #a9bdcf;
  font-size: 10px;
  margin-top: 2px;
}

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

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 11px 13px;
  color: #c1d0df;
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 13px;
  transition: 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-item.active {
  background: #1d76c4;
  color: #fff;
  font-weight: 650;
}

.nav-icon {
  width: 19px;
  text-align: center;
  font-size: 17px;
  flex-shrink: 0;
}

.nav-section-label {
  color: #8299ad;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1px;
  padding: 22px 10px 8px;
}

.admin-nav {
  margin-top: 5px;
}

.logout-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #c1d0df;
  font-size: 13px;
  text-align: left;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.main-area {
  flex: 1;
  min-width: 0;
  padding: 0 27px 24px;
}

/* TOPBAR */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 83px;
  gap: 15px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.topbar-title h2 {
  font-size: 21px;
  font-weight: 750;
}

.topbar-title p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 17px;
}

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

.menu-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-size: 22px;
}

/* FILTERS */

.dashboard-context {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  margin-bottom: 22px;
}

.site-selector-wrap,
.period-selector-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dashboard-context label {
  font-size: 11px;
  font-weight: 700;
  color: #68758a;
}

.dashboard-context select,
.dashboard-context input {
  min-width: 190px;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.dashboard-context select:focus,
.dashboard-context input:focus {
  border-color: var(--primary);
}

/* WELCOME BANNER */

.welcome-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 155px;
  padding: 25px 29px;
  margin-bottom: 21px;
  border-radius: 16px;
  background: linear-gradient(110deg, #173a58, #1b6698);
  color: #fff;
  overflow: hidden;
  position: relative;
}

.welcome-eyebrow {
  color: #a7d9ff;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1.8px;
}

.welcome-banner h2 {
  font-size: 24px;
  margin: 7px 0;
}

.welcome-banner p {
  color: #d2e7f7;
  font-size: 12px;
}

.welcome-decoration {
  font-size: 65px;
  font-weight: 900;
  opacity: 0.11;
  transform: rotate(-8deg);
  padding-right: 20px;
}

/* KPI CARDS */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 21px;
}

.kpi-card {
  min-width: 0;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-card .kpi-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  margin-top: 7px;
  line-height: 1.2;
}

.kpi-card .kpi-description {
  color: var(--muted);
  font-size: 10px;
  margin-top: 6px;
}

.kpi-card .kpi-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 17px;
  margin-bottom: 10px;
  background: var(--primary-light);
  color: var(--primary);
}

/* CONTENT GRID AND PANELS */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 17px;
  margin-bottom: 18px;
}

.secondary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-header h3 {
  font-size: 14px;
  font-weight: 750;
}

.panel-header p {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* TABLE */

.table-container {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 380px;
}

thead th {
  padding: 11px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 750;
  color: #64748b;
  background: #f7f9fc;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 10px;
  font-size: 12px;
  border-bottom: 1px solid #edf1f6;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody td:first-child {
  font-weight: 600;
  color: #344256;
}

tbody td:not(:first-child) {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ACTIVITY SUMMARY */

.activity-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid #edf1f6;
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: #edf5ff;
  color: var(--primary);
}

.activity-info {
  flex: 1;
  min-width: 0;
}

.activity-info strong {
  display: block;
  font-size: 12px;
}

.activity-info small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
}

.activity-count {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy);
}

/* COMPLIANCE */

.compliance-stat {
  margin: 13px 0;
}

.compliance-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 12px;
}

.compliance-stat-header strong {
  font-weight: 750;
}

.progress-track {
  width: 100%;
  height: 9px;
  border-radius: 20px;
  background: #edf1f5;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: var(--success);
  transition: width 0.3s ease;
}

.progress-bar.warning {
  background: var(--warning);
}

.progress-bar.danger {
  background: var(--danger);
}

.compliance-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  margin-top: 17px;
}

.compliance-detail {
  padding: 13px;
  border-radius: 10px;
  background: #f7f9fc;
}

.compliance-detail small {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.compliance-detail strong {
  display: block;
  font-size: 19px;
  margin-top: 4px;
}

/* RECOGNITION */

.recognition-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px;
  background: #fffaf0;
  border: 1px solid #f5e7c5;
  border-radius: 12px;
}

.recognition-photo {
  width: 72px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #f2e8d5;
  overflow: hidden;
}

.recognition-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.recognition-info {
  min-width: 0;
}

.recognition-info .award-label {
  color: #b27a1d;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.recognition-info h4 {
  font-size: 14px;
  margin: 4px 0;
}

.recognition-info p {
  font-size: 11px;
  color: #776950;
}

/* EMERGENCY */

.emergency-panel {
  margin-bottom: 18px;
}

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

.emergency-card {
  padding: 13px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.emergency-card small {
  display: block;
  font-size: 10px;
  color: var(--muted);
}

.emergency-card strong {
  display: block;
  font-size: 13px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.emergency-message {
  padding: 14px;
  margin-top: 14px;
  border-left: 4px solid var(--warning);
  border-radius: 7px;
  background: var(--warning-bg);
  font-size: 12px;
}

/* OTHER PAGES */

.page-placeholder {
  min-height: 250px;
}

.page-placeholder h3 {
  font-size: 20px;
  margin: 10px 0;
}

.page-placeholder p {
  color: var(--muted);
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 22px;
}

/* FOOTER */

.app-footer {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 20px 0 5px;
  font-size: 10px;
  color: #95a0af;
}

/* TOAST */

.toast-container {
  position: fixed;
  z-index: 9999;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  max-width: 330px;
  padding: 13px 17px;
  border-radius: 10px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.25s ease;
}

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

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

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

/* RESPONSIVE: TABLETS */

@media (max-width: 1100px) {
  .sidebar {
    width: 225px;
    min-width: 225px;
  }

  .main-area {
    padding: 0 20px 20px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .secondary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* RESPONSIVE: MOBILE */

@media (max-width: 760px) {
  .app-screen {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 270px;
    height: 100vh;
    min-height: 100vh;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.15);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-area {
    width: 100%;
    padding: 0 14px 20px;
  }

  .topbar {
    min-height: 70px;
    margin-bottom: 17px;
    gap: 10px;
  }

  .menu-toggle {
    display: block;
    flex-shrink: 0;
  }

  .topbar-title {
    flex: 1;
    min-width: 0;
  }

  .topbar-title h2 {
    font-size: 18px;
  }

  .topbar-title p {
    font-size: 10px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .date-label {
    display: none;
  }

  .topbar-actions .user-avatar {
    width: 32px;
    height: 32px;
  }

  .dashboard-context {
    gap: 10px;
    margin-bottom: 16px;
  }

  .site-selector-wrap,
  .period-selector-wrap {
    flex: 1;
    min-width: 0;
  }

  .dashboard-context select,
  .dashboard-context input {
    width: 100%;
    min-width: 0;
    font-size: 12px;
  }

  .welcome-banner {
    min-height: 125px;
    padding: 20px;
    margin-bottom: 15px;
  }

  .welcome-banner h2 {
    font-size: 19px;
  }

  .welcome-banner p {
    font-size: 11px;
    max-width: 220px;
  }

  .welcome-decoration {
    font-size: 44px;
    padding-right: 0;
  }

  .kpi-grid {
    gap: 10px;
    margin-bottom: 15px;
  }

  .kpi-card {
    padding: 13px;
    border-radius: 12px;
  }

  .kpi-card .kpi-label {
    font-size: 10px;
  }

  .kpi-card .kpi-value {
    font-size: 23px;
  }

  .kpi-card .kpi-description {
    font-size: 9px;
  }

  .kpi-card .kpi-icon {
    width: 30px;
    height: 30px;
    margin-bottom: 8px;
  }

  .dashboard-grid,
  .secondary-grid {
    grid-template-columns: 1fr;
    gap: 13px;
    margin-bottom: 13px;
  }

  .panel {
    padding: 15px;
    border-radius: 12px;
  }

  .panel-header {
    margin-bottom: 13px;
  }

  .panel-header h3 {
    font-size: 13px;
  }

  .panel-header p {
    font-size: 10px;
  }

  thead th {
    padding: 10px 8px;
    font-size: 10px;
  }

  tbody td {
    padding: 10px 8px;
    font-size: 11px;
  }

  .emergency-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .emergency-card {
    padding: 11px;
  }

  .emergency-card strong {
    font-size: 12px;
  }

  .app-footer {
    padding-top: 15px;
  }

  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: none;
  }
}

/* SMALL MOBILE */

@media (max-width: 380px) {
  .login-card {
    padding: 24px 20px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-card .kpi-value {
    font-size: 21px;
  }

  .welcome-decoration {
    display: none;
  }

  .emergency-grid {
    grid-template-columns: 1fr;
  }
}

/* REDUCED MOTION */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
