/* ============================================================
   KAIZEN DESIGN SYSTEM — Robot Welding App
   Based on ui_ux_guidelines.md design tokens
   ============================================================ */

/* === DESIGN TOKENS === */
:root {
  --brand-primary:       #C53A3A;
  --brand-primary-dark:  #A72E2E;
  --brand-primary-light: #F9ECEC;
  --neutral-50:          #FAFAFA;
  --neutral-100:         #F6F7F8;
  --neutral-200:         #EEF0F2;
  --neutral-300:         #E6E9EC;
  --neutral-400:         #CDD2D8;
  --neutral-500:         #9CA3AF;
  --neutral-600:         #6B7280;
  --neutral-700:         #374151;
  --neutral-800:         #1F2937;
  --neutral-900:         #111827;
  --text-default:        #111827;
  --text-muted:          #6B7280;
  --white:               #FFFFFF;

  --success:        #16A34A;
  --success-light:  #DCFCE7;
  --warning:        #F59E0B;
  --warning-light:  #FEF9C3;
  --error:          #DC2626;
  --error-light:    #FEE2E2;
  --info:           #2563EB;
  --info-light:     #DBEAFE;
  --pending:        #9CA3AF;
  --pending-light:  #F3F4F6;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-soft: 0 6px 18px rgba(16,24,40,0.06);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-dropdown: 0 10px 25px rgba(0,0,0,0.12);

  --sidebar-width:   240px;
  --topbar-height:   60px;
  --font:            'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:       'Consolas', 'Courier New', monospace;
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-default);
  background: var(--neutral-100);
  min-height: 100vh;
}

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

img { max-width: 100%; display: block; }

/* === TYPOGRAPHY === */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem;     font-weight: 600; }
h5 { font-size: 0.9rem;   font-weight: 600; }
small { font-size: 0.8125rem; }

/* === LAYOUT — TOPBAR === */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 0;
  z-index: 1000;
  border-bottom: 1px solid var(--neutral-200);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 100%;
  color: var(--text-default);
  text-decoration: none;
  min-width: var(--sidebar-width);
  border-right: 1px solid var(--neutral-200);
}
.topbar-brand:hover { text-decoration: none; background: var(--neutral-100); }

.topbar-logo-icon {
  width: 36px; height: 36px;
  background: var(--neutral-800);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800; color: var(--white);
  flex-shrink: 0;
}

.topbar-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-brand-name { font-size: 0.95rem; font-weight: 700; color: var(--brand-primary); }
.topbar-brand-sub  { font-size: 0.7rem;  color: var(--text-muted); }

.topbar-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  line-height: 1;
  user-select: none;
}
.topbar-clock-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.topbar-clock-time {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-default);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-default);
}

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
  position: relative;
}
.topbar-user:hover { background: var(--neutral-100); }
.topbar-user-name { font-size: 0.875rem; font-weight: 600; color: var(--text-default); }
.topbar-user-role {
  font-size: 0.7rem; color: var(--text-muted);
  background: var(--neutral-200);
  border-radius: 20px; padding: 1px 7px;
}

.topbar-divider { width: 1px; height: 28px; background: var(--neutral-200); }

.topbar-logout {
  color: var(--text-muted);
  font-size: 0.875rem;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.topbar-logout:hover { background: var(--neutral-100); text-decoration: none; color: var(--text-default); }

.sidebar-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  padding: 8px; border-radius: var(--radius-md);
  display: none;
  transition: background 0.15s;
}
.sidebar-toggle-btn:hover { background: var(--neutral-100); }

/* === LAYOUT — SIDEBAR === */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--white);
  border-right: 1px solid var(--neutral-300);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  transition: transform 0.25s ease;
}

.sidebar-nav { padding: 12px 8px; }

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-500);
  padding: 12px 10px 4px;
}

.sidebar-nav a,
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--neutral-700);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  margin-bottom: 2px;
}
.sidebar-nav a:hover,
.sidebar-nav-item:hover { background: var(--neutral-100); color: var(--brand-primary); text-decoration: none; }

.sidebar-nav a.active,
.sidebar-nav-item.active {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 600;
}

.sidebar-nav a i,
.sidebar-nav-item i { width: 16px; text-align: center; font-size: 0.875rem; flex-shrink: 0; }

.sidebar-submenu {
  padding-left: 16px;
  margin-top: 2px;
  display: none;
}
.sidebar-submenu.open { display: block; }
.sidebar-submenu a {
  font-size: 0.83rem;
  padding: 7px 10px;
}
.sidebar-submenu-group {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 10px 10px 3px;
  opacity: 0.75;
}
.sidebar-submenu-group:first-child { padding-top: 4px; }

.sidebar-nav-item .chevron {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.sidebar-nav-item.open .chevron { transform: rotate(90deg); }

.sidebar-divider {
  height: 1px;
  background: var(--neutral-200);
  margin: 8px 0;
}

/* === LAYOUT — MAIN CONTENT === */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left h1 { font-size: 1.5rem; color: var(--text-default); }
.page-header-left p  { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* === CARDS === */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--neutral-200);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
}
.card-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-default); margin: 0; }
.card-header-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
}

.card-body { padding: 20px; }

.card-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--brand-primary);
  display: inline-block;
}

/* === KPI CARDS === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-soft); }

.kpi-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.375rem;
  flex-shrink: 0;
}
.kpi-icon-red    { background: var(--brand-primary-light); color: var(--brand-primary); }
.kpi-icon-green  { background: var(--success-light);       color: var(--success); }
.kpi-icon-orange { background: var(--warning-light);       color: var(--warning); }
.kpi-icon-blue   { background: var(--info-light);          color: var(--info); }

.kpi-body { flex: 1; min-width: 0; }
.kpi-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--text-default); line-height: 1.2; }
.kpi-sub   { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 600; font-family: var(--font);
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

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

.btn-secondary {
  background: var(--white);
  color: var(--neutral-700);
  border-color: var(--neutral-300);
}
.btn-secondary:hover { background: var(--neutral-100); border-color: var(--neutral-400); color: var(--neutral-800); }

.btn-success {
  background: var(--success); color: var(--white); border-color: var(--success);
}
.btn-success:hover { background: #15803D; border-color: #15803D; color: var(--white); }

.btn-danger {
  background: var(--error); color: var(--white); border-color: var(--error);
}
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; color: var(--white); }

.btn-outline-danger {
  background: transparent; color: var(--error); border-color: var(--error);
}
.btn-outline-danger:hover { background: var(--error); color: var(--white); }

.btn-sm  { padding: 6px 12px; font-size: 0.8rem; }
.btn-xs  { padding: 3px 9px; font-size: 0.75rem; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 9px; }

/* === BADGES / STATUS === */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success  { background: var(--success-light);  color: #15803D; }
.badge-warning  { background: var(--warning-light);  color: #B45309; }
.badge-danger   { background: var(--error-light);    color: #B91C1C; }
.badge-info     { background: var(--info-light);     color: #1D4ED8; }
.badge-pending  { background: var(--pending-light);  color: var(--neutral-600); }
.badge-primary  { background: var(--brand-primary-light); color: var(--brand-primary); }

/* OEE / Achievement specific */
.badge-oee-high   { background: var(--success-light); color: #15803D; }
.badge-oee-mid    { background: var(--warning-light); color: #B45309; }
.badge-oee-low    { background: var(--error-light);   color: #B91C1C; }

/* === FORMS === */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: repeat(4, 1fr); }

.form-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.83rem; font-weight: 600;
  color: var(--neutral-700);
  margin-bottom: 5px;
}
.form-label i { color: var(--brand-primary); font-size: 0.8rem; }
.required-star { color: var(--brand-primary); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--neutral-300);
  border-radius: var(--radius-md);
  font-size: 0.875rem; font-family: var(--font);
  color: var(--text-default);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(197,58,58,0.12);
}
.form-control:disabled { background: var(--neutral-100); color: var(--neutral-500); cursor: not-allowed; }
.form-control[readonly] { background: var(--neutral-50); color: var(--text-muted); cursor: not-allowed; border-style: dashed; }
.form-control.is-invalid { border-color: var(--error); }
.form-control.is-valid   { border-color: var(--success); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint  { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--error); margin-top: 4px; display: flex; align-items: center; gap: 4px; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group-text {
  padding: 9px 12px;
  background: var(--neutral-100);
  border: 1.5px solid var(--neutral-300);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.875rem; color: var(--text-muted);
}

.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"],
.form-check input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand-primary); cursor: pointer; }

/* === TABLES === */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  color: var(--text-default);
}
.table th {
  background: var(--neutral-100);
  color: var(--neutral-600);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 14px;
  border-bottom: 2px solid var(--neutral-300);
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--neutral-200);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--neutral-50); }
.table tbody tr:last-child td { border-bottom: none; }

.table-striped tbody tr:nth-child(even) { background: var(--neutral-50); }
.table-striped tbody tr:nth-child(even):hover { background: var(--neutral-100); }

.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* === ALERTS === */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 0.875rem;
  margin-bottom: 16px;
  border-left: 4px solid transparent;
}
.alert i { margin-top: 1px; flex-shrink: 0; }
.alert-success { background: var(--success-light); color: #15803D; border-left-color: var(--success); }
.alert-danger   { background: var(--error-light);   color: #B91C1C; border-left-color: var(--error); }
.alert-warning  { background: var(--warning-light); color: #B45309; border-left-color: var(--warning); }
.alert-info     { background: var(--info-light);    color: #1D4ED8; border-left-color: var(--info); }

/* === TOAST NOTIFICATIONS === */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--neutral-900);
  color: var(--white);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-dropdown);
  max-width: 340px;
  pointer-events: all;
  animation: toastIn 0.25s ease;
}
.toast-success { background: var(--success); }
.toast-danger  { background: var(--error); }
.toast-warning { background: #B45309; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === MODAL === */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  max-width: 480px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--neutral-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h4 { font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--neutral-500);
  padding: 4px; border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--error); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--neutral-200);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* === FILTER BAR === */
.filter-bar {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: none;
}
.filter-bar.open { display: block; }
.filter-bar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

/* === SECTION HEADER (colored left border) === */
.section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border-left: 4px solid var(--brand-primary);
  background: var(--brand-primary-light);
  font-size: 0.9rem; font-weight: 600; color: var(--brand-primary);
}

/* === OEE DISPLAY === */
.oee-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.oee-item {
  text-align: center;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  background: var(--neutral-100);
}
.oee-item-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.oee-item-value { font-size: 1.5rem; font-weight: 700; margin: 4px 0; }
.oee-high { color: var(--success); }
.oee-mid  { color: var(--warning); }
.oee-low  { color: var(--error); }

/* === CHART WRAPPER === */
.chart-wrapper { position: relative; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }

/* === ENTRY TABLE (daily input) === */
.entry-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.entry-table th {
  background: var(--neutral-800);
  color: var(--white);
  padding: 9px 10px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.entry-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--neutral-200);
  vertical-align: middle;
}
.entry-table tbody tr:hover { background: var(--neutral-50); }
.entry-table .form-control { padding: 6px 8px; font-size: 0.83rem; }
.entry-table select.form-control { min-width: 110px; }
.entry-table .remove-row-btn {
  background: none; border: none; cursor: pointer;
  color: var(--neutral-400); padding: 4px 6px;
  border-radius: var(--radius-sm); font-size: 1rem;
  transition: color 0.15s;
}
.entry-table .remove-row-btn:hover { color: var(--error); }

/* === SUMMARY SECTION === */
.daily-summary-card {
  background: var(--neutral-100);
  border: 1.5px dashed var(--neutral-300);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 20px;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; color: var(--neutral-400); }
.empty-state p { font-size: 0.9rem; }

/* === PAGINATION (DataTables override) === */
.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 4px 10px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--neutral-300) !important;
  margin: 0 2px !important;
  font-size: 0.83rem !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--neutral-800) !important;
  border-color: var(--neutral-800) !important;
  color: var(--white) !important;
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--neutral-300);
  border-radius: var(--radius-md);
  padding: 5px 8px;
  font-size: 0.83rem;
  font-family: var(--font);
}

/* === PROGRESS BAR === */
.progress-bar-wrap { background: var(--neutral-200); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { height: 8px; border-radius: 20px; transition: width 0.4s; }
.progress-bar-success { background: var(--success); }
.progress-bar-warning { background: var(--warning); }
.progress-bar-danger  { background: var(--error); }

/* === LOGIN PAGE === */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--neutral-800) 0%, var(--neutral-900) 100%);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: 40px;
  width: 100%; max-width: 400px;
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px; justify-content: center;
}
.login-logo-icon {
  width: 48px; height: 48px;
  background: var(--neutral-800);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 1.4rem; font-weight: 800;
}
.login-title { font-size: 1.1rem; font-weight: 700; color: var(--text-default); }
.login-sub   { font-size: 0.8rem; color: var(--text-muted); }

/* === UTILS === */
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fw-600  { font-weight: 600; }
.text-muted  { color: var(--text-muted) !important; }
.text-success{ color: var(--success) !important; }
.text-danger { color: var(--error) !important; }
.text-warning{ color: var(--warning) !important; }
.text-primary{ color: var(--brand-primary) !important; }
.small { font-size: 0.8125rem; }

.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; } .mt-6 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; }  .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; } .mb-6 { margin-bottom: 32px; }
.ms-auto { margin-left: auto; }
.p-0 { padding: 0 !important; }
.w-100 { width: 100%; }

.divider { height: 1px; background: var(--neutral-200); margin: 16px 0; }

/* === DATE BUTTON ROW === */
.date-btn-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.date-btn {
  padding: 6px 14px;
  border: 1px solid var(--neutral-300);
  border-radius: 6px;
  background: var(--white);
  color: var(--text-default);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}
.date-btn:hover { background: var(--neutral-100); border-color: var(--neutral-400); }
.date-btn.active {
  background: var(--neutral-800);
  border-color: var(--neutral-800);
  color: #fff;
  font-weight: 600;
}

/* === ROBOT TABS === */
.robot-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--neutral-200);
  margin-bottom: 0;
  flex-wrap: wrap;
  background: var(--white);
}
.robot-tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--neutral-500);
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
}
.robot-tab-btn:hover { color: var(--text-default); }
.robot-tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}
.robot-tab-content { display: none; }
.robot-tab-content.active { display: block; }

/* === ENTRY TABLE (compact tabular production entry) === */
.entry-table { margin-bottom: 0; }
.entry-table thead th {
  padding: 7px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--neutral-50);
}
.entry-table td {
  padding: 5px 8px;
  vertical-align: middle;
}
.entry-table tr.entry-has-actual > td:first-child {
  border-left: 3px solid var(--success);
}
.entry-table tr:not(.entry-has-actual) > td:first-child {
  border-left: 3px solid var(--warning);
}
.entry-table tr.entry-subrow > td {
  border-top: none;
  padding: 3px 10px 7px;
  background: var(--neutral-50);
}
.entry-table .form-control {
  padding: 4px 7px;
  font-size: 0.85rem;
  height: auto;
}

/* === SEARCHABLE SELECT (.ss-*) — vanilla JS, no external lib === */
.ss-wrap                   { position: relative; display: block; }
.ss-display                { display: flex; align-items: center; min-height: 32px; padding: 4px 26px 4px 8px; border: 1px solid var(--neutral-300); border-radius: var(--radius-sm); background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 10px; font-size: 0.83rem; font-family: inherit; cursor: pointer; user-select: none; color: var(--text-default); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: border-color 0.15s; }
.ss-display:focus          { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 2px rgba(197,58,58,0.12); }
.ss-dropdown               { position: absolute; top: calc(100% + 2px); left: 0; min-width: 100%; background: var(--white); border: 1px solid var(--neutral-300); border-radius: var(--radius-sm); box-shadow: 0 4px 16px rgba(0,0,0,0.10); z-index: 9999; }
.ss-search-wrap            { padding: 6px 6px 4px; border-bottom: 1px solid var(--neutral-200); }
.ss-search                 { width: 100%; box-sizing: border-box; padding: 5px 8px; border: 1px solid var(--neutral-300); border-radius: var(--radius-sm); font-size: 0.8rem; font-family: inherit; outline: none; }
.ss-search:focus           { border-color: var(--brand-primary); }
.ss-list                   { max-height: 200px; overflow-y: auto; }
.ss-option                 { padding: 7px 10px; font-size: 0.83rem; cursor: pointer; color: var(--text-default); white-space: nowrap; }
.ss-option:hover           { background: var(--neutral-100); }
.ss-option.ss-selected     { background: var(--brand-primary-light); color: var(--brand-primary); font-weight: 600; }
.ss-option.ss-nomatch      { color: var(--text-muted); font-style: italic; cursor: default; }
.ss-option.ss-nomatch:hover { background: none; }
/* Compact for table cells */
.entry-table .ss-wrap      { min-width: 110px; max-width: 160px; }
.entry-table .ss-display   { min-height: 28px; padding: 3px 24px 3px 6px; font-size: 0.83rem; }

/* === AUTO-SAVE INDICATOR === */
.row-save-ind {
  font-size: 0.68rem;
  min-height: 14px;
  transition: opacity 0.3s;
  line-height: 1.4;
}
.row-save-ind.saving::after { content: '⟳ Saving…'; color: var(--text-muted); }
.row-save-ind.saved::after  { content: '✓ Saved';   color: var(--success); }
.row-save-ind.error::after  { content: '✗ Error';   color: var(--error); }

/* === INLINE REJECT PANEL === */
.rej-subrow-cell {
  padding: 0 !important;
  background: #fffdf5;
  border-top: none !important;
}
.rej-inner {
  padding: 10px 16px 12px;
  border-top: 2px solid var(--warning-light);
}
.rej-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--neutral-100);
}
.rej-item:last-of-type { border-bottom: none; }

/* === COLLAPSIBLE ENTRY SECTIONS === */
.section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-default);
  border-bottom: 1px solid var(--neutral-200);
  margin-bottom: 10px;
  transition: color 0.15s;
}
.section-toggle:hover { color: var(--brand-primary); }
.section-chevron {
  transition: transform 0.2s;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.section-toggle.open .section-chevron { transform: rotate(180deg); }
.section-body { display: none; }
.section-body.open { display: block; }

/* === SORTABLE COLUMNS === */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: var(--neutral-50); }
th[data-sort='asc']::after  { content: ' \2191'; color: var(--brand-primary); font-size: 0.75em; }
th[data-sort='desc']::after { content: ' \2193'; color: var(--brand-primary); font-size: 0.75em; }
th.sortable:focus { outline: 2px solid var(--brand-primary); outline-offset: -2px; }

/* === KAIZEN TABLE PAGINATION === */

/* Search bar — top of card */
.kt-search-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--neutral-200);
}
.kt-search-wrap {
  position: relative;
  max-width: 340px;
}
.kt-search-wrap .fa-magnifying-glass {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
}
.kt-search-wrap input {
  padding-left: 30px;
}

/* Footer row — bottom of card: info (left) | pagination (center) | perpage (right) */
.kt-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--neutral-200);
  flex-wrap: wrap;
}
.kt-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 130px;
}
.kt-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
.kt-perpage {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: auto;
}
.kt-perpage select {
  width: auto;
  padding: 4px 8px;
}

/* Legacy: keep .kt-controls working for any old usages */
.kt-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--neutral-200);
}
.pg-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border: 1px solid var(--neutral-300);
  border-radius: 6px;
  background: var(--white);
  color: var(--text-default);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pg-btn:hover:not(:disabled) {
  background: var(--neutral-100);
  border-color: var(--neutral-400);
}
.pg-btn.active {
  background: var(--neutral-800);
  border-color: var(--neutral-800);
  color: #fff;
  font-weight: 700;
}
.pg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pg-btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 1px;
}
.pg-ellipsis {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0 4px;
  user-select: none;
}
.pg-goto {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 8px;
  cursor: default;
}
.pg-goto-input {
  width: 52px;
  padding: 3px 6px;
  border: 1px solid var(--neutral-300);
  border-radius: 4px;
  font-size: 0.8rem;
  text-align: center;
  line-height: 1;
}
@media (max-width: 600px) {
  .pg-num, .pg-ellipsis { display: none; }
  .pg-goto { display: none; }
}

/* === ARC METRICS SECTION ============================================== */
.arc-metrics-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.arc-metric-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-default);
  min-width: 120px;
  flex-shrink: 0;
  padding-bottom: 6px; /* align with inputs */
}
.arc-metric-inputs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.arc-metric-sublabel {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.arc-metric-arrow {
  color: var(--neutral-400);
  font-size: 1rem;
  padding-bottom: 8px;
  flex-shrink: 0;
}
.arc-metric-diff {
  font-size: 0.88rem;
  min-width: 90px;
  padding-bottom: 7px;
  flex-shrink: 0;
}
.hms-split {
  display: flex;
  align-items: center;
  gap: 3px;
}
.hms-part {
  width: 54px !important;
  text-align: center !important;
  padding: 6px 4px !important;
  font-size: 0.85rem !important;
}
.hms-part.hms-h {
  width: 70px !important; /* hours can exceed 9999 */
}
.hms-part.hms-ms {
  width: 48px !important;
}
.hms-sep {
  color: var(--neutral-400);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

/* === OEE REPORT ======================================================= */
.gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.gauge-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.gauge-row {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 14px 10px 12px;
  flex-wrap: wrap;
  gap: 4px;
}
.oee-robot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.oee-period-tabs {
  display: flex;
  gap: 2px;
  background: var(--neutral-100);
  padding: 3px;
  border-radius: var(--radius-md);
}
.oee-period-tab {
  padding: 6px 18px;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.oee-period-tab:hover { color: var(--text-default); }
.oee-period-tab.active {
  background: var(--white);
  color: var(--text-default);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.oee-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.oee-period-label {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.oee-summary-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.oee-summary-table th {
  background: var(--neutral-800);
  color: var(--white);
  padding: 8px 10px;
  text-align: left;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.oee-summary-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--neutral-200);
  vertical-align: middle;
  white-space: nowrap;
}
.oee-summary-table tbody tr:hover { background: var(--neutral-50); }
@media (max-width: 900px) {
  .oee-robot-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .gauge-row { justify-content: center; }
  .oee-filter-bar { gap: 6px; }
}

/* === RESPONSIVE === */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .oee-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar-toggle-btn { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-dropdown); }
  .main-content { margin-left: 0; padding: 16px; }
  .topbar-brand { min-width: unset; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .table th, .table td { padding: 9px 10px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .oee-grid { grid-template-columns: repeat(2, 1fr); }
  .login-card { padding: 28px 20px; }
}
