/* ── Reset & Variables ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #0057B8;
  --blue-dark:  #00409A;
  --blue-light: #E8F0FB;
  --accent:     #FF6B00;
  --green:      #16A34A;
  --red:        #DC2626;
  --yellow:     #CA8A04;
  --gray-50:    #F8FAFC;
  --gray-100:   #F1F5F9;
  --gray-200:   #E2E8F0;
  --gray-400:   #94A3B8;
  --gray-600:   #475569;
  --gray-800:   #1E293B;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  min-height: 100vh;
}

/* ── Pages ────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Login ────────────────────────────────────────────────────── */
#page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0057B8 0%, #003580 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-weight: 700;
  font-size: 18px;
  color: var(--blue);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--gray-400);
  margin-bottom: 28px;
  font-size: 13px;
}

/* ── Forms & Fields ───────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field input,
.field select {
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-800);
  background: white;
  transition: border-color .15s;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,87,184,.12);
}

.field-checkbox {
  justify-content: flex-end;
  padding-top: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  text-transform: none;
  letter-spacing: 0;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

.hint { font-size: 11px; color: var(--gray-400); font-weight: 400; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
}

/* Login form button full width */
#login-form .btn-primary { width: 100%; margin-top: 8px; padding: 12px; }
#login-form .field { margin-bottom: 16px; }

/* ── Navbar ───────────────────────────────────────────────────── */
.navbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--blue);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user {
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 500;
}

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Cards ────────────────────────────────────────────────────── */
.filters-card,
.results-card,
.dashboard-placeholder {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.filters-card h2,
.results-card h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--gray-800);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.filters-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Results ──────────────────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.badge {
  background: var(--blue-light);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.jql-box {
  font-size: 11px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--gray-600);
  max-width: 700px;
  word-break: break-all;
  flex: 1;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}

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

.data-table th {
  background: var(--gray-50);
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--blue-light); }

.ticket-key {
  font-weight: 700;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.summary-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-open    { background: #DBEAFE; color: #1D4ED8; }
.status-progress{ background: #FEF3C7; color: #92400E; }
.status-resolved{ background: #DCFCE7; color: #166534; }
.status-closed  { background: var(--gray-100); color: var(--gray-600); }
.status-default { background: var(--gray-100); color: var(--gray-600); }

/* Priority */
.priority-highest { color: #991B1B; font-weight: 700; }
.priority-high    { color: var(--red); font-weight: 600; }
.priority-medium  { color: var(--yellow); font-weight: 600; }
.priority-low     { color: var(--green); }
.priority-lowest  { color: var(--gray-400); }

/* Time cells */
.time-cell { font-family: monospace; font-size: 12px; white-space: nowrap; }
.time-good { color: var(--green); }
.time-warn { color: var(--yellow); }
.time-bad  { color: var(--red); }
.time-pending { color: var(--gray-400); font-style: italic; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-800); }

.modal-body { padding: 24px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-item label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: block;
  margin-bottom: 3px;
}

.detail-item span {
  font-size: 14px;
  color: var(--gray-800);
}

.times-section h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--gray-800);
  border-top: 1px solid var(--gray-200);
  padding-top: 16px;
}

.times-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.time-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 14px 16px;
}

.time-card .label { font-size: 11px; color: var(--gray-400); font-weight: 600; text-transform: uppercase; }
.time-card .value { font-size: 22px; font-weight: 700; color: var(--blue); margin: 4px 0; font-family: monospace; }
.time-card .sub   { font-size: 11px; color: var(--gray-400); }

.states-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.states-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-200);
}
.states-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
}
.states-table tr:last-child td { border-bottom: none; }

.bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bar-bg {
  flex: 1;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
  transition: width .4s ease;
}

/* ── Dashboard placeholder ────────────────────────────────────── */
.dashboard-placeholder {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--gray-200);
  background: var(--gray-50);
}

.placeholder-content {
  text-align: center;
  color: var(--gray-400);
}

.placeholder-content svg { margin-bottom: 12px; opacity: .4; }
.placeholder-content p { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.placeholder-content small { font-size: 12px; }

/* ── Utilities ────────────────────────────────────────────────── */
.hidden { display: none !important; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--gray-600);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .navbar { padding: 0 16px; }
  .detail-grid, .times-grid { grid-template-columns: 1fr; }
}
