/* ======================================================
   EA FACTORY - EXECUTIVE DASHBOARD CSS v1.0
====================================================== */

:root {
  --primary: #047857;
  --primary-dark: #065f46;
  --primary-soft: #d1fae5;
  --blue: #2563eb;
  --warning: #f59e0b;
  --danger: #dc2626;
  --success: #16a34a;

  --ink: #0f172a;
  --muted: #64748b;
  --soft: #94a3b8;
  --bg: #eef7f2;
  --panel: rgba(255, 255, 255, 0.92);
  --line: rgba(148, 163, 184, 0.28);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;

  --shadow: 0 18px 45px rgba(15, 23, 42, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Kanit", "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(4, 120, 87, 0.18), transparent 28%),
    radial-gradient(circle at 90% 6%, rgba(37, 99, 235, 0.12), transparent 28%),
    linear-gradient(135deg, #f8fafc 0%, #eef7f2 55%, #ecfeff 100%);
}

button,
input,
select {
  font: inherit;
}

.exec-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 28px 34px 56px;
}

/* ================= HEADER ================= */

.exec-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 24px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.16);
}

.brand-icon .material-symbols-outlined {
  font-size: 38px;
}

.exec-header h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.1;
  font-weight: 950;
}

.exec-header p {
  margin: 8px 0 0;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.user-chip {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  white-space: nowrap;
}

/* ================= BUTTONS ================= */

.btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border: 0;
  border-radius: 14px;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-dark {
  color: white;
  background: #334155;
}

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

.btn-light {
  color: var(--primary-dark);
  background: #ecfdf5;
}

/* ================= FILTER ================= */

.filter-card,
.metric-card,
.summary-card,
.chart-card,
.table-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.filter-card {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr) auto auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
  margin-bottom: 18px;
}

.form-group {
  display: grid;
  gap: 7px;
}

.form-group label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.form-group input,
.form-group select {
  min-height: 46px;
  width: 100%;
  padding: 10px 13px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 14px;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(4, 120, 87, 0.12);
}

/* ================= KPI ================= */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card {
  position: relative;
  min-height: 150px;
  overflow: hidden;
  padding: 20px;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--primary);
}

.metric-card.success::after {
  background: var(--success);
}

.metric-card.warning::after {
  background: var(--warning);
}

.metric-card.danger::after {
  background: var(--danger);
}

.metric-card span {
  color: var(--muted);
  font-weight: 900;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 950;
  line-height: 1.05;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--soft);
  line-height: 1.45;
}

.metric-card.success strong {
  color: var(--success);
}

.metric-card.warning strong {
  color: #d97706;
}

.metric-card.danger strong {
  color: var(--danger);
}

/* ================= SUMMARY ================= */

.summary-card,
.table-card {
  padding: 22px;
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-head h2,
.chart-card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 950;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.exec-insight-box {
  padding: 18px;
  color: #064e3b;
  line-height: 1.75;
  background: #fdfdec;
  border: 1px solid #f7ecbb;
  /* background: #ecfdf5;
  border: 1px solid #bbf7d0; */
  border-radius: 18px;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}

.result-success {
  color: #166534;
  background: #dcfce7;
}

.result-warning {
  color: #92400e;
  background: #fef3c7;
}

.result-danger {
  color: #991b1b;
  background: #fee2e2;
}

.result-none {
  color: #475569;
  background: #e2e8f0;
}

/* ================= CHARTS ================= */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.chart-card {
  min-height: 360px;
  padding: 20px;
}

.chart-card h2 {
  margin-bottom: 14px;
}

.chart-card canvas {
  width: 100% !important;
  height: 290px !important;
}

/* ================= TABLE ================= */

.table-scroll {
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: #475569;
  background: #f8fafc;
  font-size: 13px;
  white-space: nowrap;
}

.text-right {
  text-align: right !important;
}

.empty-cell {
  padding: 24px !important;
  color: var(--muted);
  text-align: center !important;
}

/* ================= MACHINE SUMMARY ================= */

.machine-summary-list {
  display: grid;
  gap: 14px;
}

.dept-machine-group {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.dept-machine-title {
  padding: 10px 14px;
  color: #0f172a;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 950;
}

.machine-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.machine-item strong {
  font-weight: 950;
}

.machine-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.55;
}

.machine-value {
  min-width: 190px;
  text-align: right;
}

.machine-value strong {
  font-size: 22px;
}

.machine-danger {
  border-color: rgba(220, 38, 38, 0.45);
  background: linear-gradient(135deg, #fef2f2, #ffffff);
}

.machine-danger .machine-value strong {
  color: var(--danger);
}

.machine-warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, #fffbeb, #ffffff);
}

.machine-warning .machine-value strong {
  color: #d97706;
}

.machine-normal {
  border-color: rgba(22, 163, 74, 0.25);
}

.machine-normal .machine-value strong {
  color: var(--success);
}

/* ================= RESPONSIVE ================= */

@media (max-width: 1100px) {
  .exec-header {
    flex-direction: column;
  }

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

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

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

@media (max-width: 720px) {
  .exec-shell {
    padding: 14px 12px 42px;
  }

  .exec-header {
    padding: 18px;
  }

  .brand-block {
    align-items: flex-start;
  }

  .brand-icon {
    width: 50px;
    height: 50px;
    border-radius: 18px;
  }

  .header-actions,
  .filter-card,
  .metric-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .header-actions {
    display: grid;
  }

  .btn,
  .user-chip {
    width: 100%;
  }

  .section-head {
    flex-direction: column;
  }

  .machine-item {
    flex-direction: column;
    align-items: stretch;
  }

  .machine-value {
    min-width: 0;
    text-align: left;
  }
}


/* ================= DEPARTMENT SUMMARY HIGHLIGHT ================= */

.table-card.department-summary-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(120, 60, 4, 0.18);
  background:  #fdfdec;
  /* background: */
    /* linear-gradient(135deg, rgba(236, 253, 245, 0.98), rgba(255, 255, 255, 0.92)); */
}

.table-card.department-summary-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, #ecb706, #ee6c22, #eed66c);
}

.department-summary-card .section-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #064e3b;
}

.department-summary-card .section-head h2::before {
  content: "analytics";
  font-family: "Material Symbols Outlined";
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, #047857, #16a34a);
  border-radius: 14px;
  font-size: 25px;
}

.department-summary-card .data-table {
  border-collapse: separate;
  border-spacing: 0 10px;
}

.department-summary-card .data-table thead th {
  color: #064e3b;
  background: #d1fae5;
  border-bottom: 0;
  font-size: 14px;
}

.department-summary-card .data-table tbody tr {
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.department-summary-card .data-table tbody td {
  border-bottom: 0;
  padding: 16px 14px;
}

.department-summary-card .data-table tbody td:first-child {
  border-radius: 16px 0 0 16px;
}

.department-summary-card .data-table tbody td:last-child {
  border-radius: 0 16px 16px 0;
}

.department-summary-card .data-table tbody td:nth-child(1) strong {
  color: #0f172a;
  font-size: 16px;
}

.department-summary-card .data-table tbody td:nth-child(4) strong {
  font-size: 18px;
}


.dashboard-update{
    display:flex;
    flex-direction:column;
    align-items:flex-end;
    margin-top:8px;
    font-size:13px;
    line-height:1.45;
}

.update-status{
    font-weight:800;
    color:#ffffff;
}

.update-date{
    color:rgba(255,255,255,.82);
    font-size:12px;
}