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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f6fa;
  color: #1a1a2e;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid #e5e7eb;
  text-align: center;
}

.brand img { display: block; margin: 0 auto; }

.brand-subtitle {
  font-family: "Poppins", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #828e9d;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 8px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

#filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#filter-form input[type="date"],
#filter-form input[type="text"] {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  background: #fff;
  color: #1a1a2e;
}

#filter-form button {
  border: none;
  background: #4E79A7;
  color: #fff;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#filter-form button:hover { background: #3d6185; }

.zoho-connect-btn {
  font-size: 12px;
  color: #fff;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  background: #059669;
  font-weight: 600;
  white-space: nowrap;
}

.zoho-connect-btn:hover { background: #047857; }

.zoho-connected-badge {
  font-size: 12px;
  color: #059669;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  background: #ecfdf5;
  white-space: nowrap;
}

.csv-btn {
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #6b7280;
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  white-space: nowrap;
}

.csv-btn:hover { background: #f3f4f6; }

.view-toggle {
  display: flex;
  gap: 0;
  background: #e5e7eb;
  border-radius: 8px;
  padding: 3px;
}

.view-toggle button {
  border: none;
  background: none;
  padding: 6px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: #6b7280;
  transition: background .15s, color .15s;
}

.view-toggle button.active {
  background: #fff;
  color: #1a1a2e;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

#status {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 4px;
  min-height: 20px;
}

#status.error { color: #E15759; }

#cache-bar {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 16px;
  min-height: 18px;
}

#cache-bar a {
  color: #4E79A7;
  text-decoration: none;
  cursor: pointer;
  margin-left: 4px;
}

#cache-bar a:hover { text-decoration: underline; }

section { margin-bottom: 48px; }

.month-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

h2 { font-size: 18px; font-weight: 700; color: #1a1a2e; }

.total-badge {
  display: inline-block;
  background: #4E79A7;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  margin-top: 6px;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 150px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  border-left: 4px solid #ccc;
  cursor: pointer;
  user-select: none;
  transition: opacity .2s, box-shadow .15s;
}

.card.dimmed { opacity: 0.35; }
.card.active { box-shadow: 0 0 0 2px #4E79A7; }
.card-all { border-left-color: #4E79A7; }
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.13); }
.card-name { font-size: 11px; color: #6b7280; font-weight: 500; margin-bottom: 5px; }
.card-hours { font-size: 20px; font-weight: 700; color: #1a1a2e; }

.chart-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.chart-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.chart-box-main { flex: 1 1 0; min-width: 0; }
.chart-box-pie { flex: 0 0 260px; width: 260px; }

.split-grid { display: flex; flex-direction: column; gap: 16px; }

.split-item {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.split-user-label {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 14px;
  padding-left: 10px;
  border-left: 3px solid #ccc;
}

.split-user-hours { font-weight: 400; color: #6b7280; margin-left: 6px; }

canvas { width: 100% !important; }

/* Fixed-height wrappers so chart plot area stays consistent regardless of legend size */
.chart-canvas-wrap {
  position: relative;
  width: 100%;
}
.chart-canvas-wrap-main { height: 360px; }
.chart-canvas-wrap-split { height: 320px; }
.chart-canvas-wrap-pie { height: 260px; width: 100%; }
.chart-canvas-wrap canvas { height: 100% !important; }

@media (max-width: 760px) {
  .chart-canvas-wrap-main { height: 320px; }
  .chart-canvas-wrap-split { height: 300px; }
  .chart-canvas-wrap-pie { height: 240px; }
}

#popover {
  position: fixed;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
  padding: 16px 18px;
  min-width: 260px;
  max-width: 380px;
  z-index: 1000;
  display: none;
}

#popover.visible { display: block; }
#popover h4 { font-size: 13px; font-weight: 700; margin-bottom: 4px; color: #1a1a2e; }
#popover .pop-user { font-size: 11px; color: #6b7280; margin-bottom: 12px; }
#popover .task { padding: 8px 0; border-top: 1px solid #f0f0f0; }
#popover .task-ids { font-size: 11px; color: #6b7280; margin-bottom: 3px; }
#popover .task-summary { font-size: 13px; color: #1a1a2e; margin-bottom: 2px; }
#popover .task-hours { font-size: 12px; font-weight: 600; color: #4E79A7; }
#popover .task-total { font-size: 11px; color: #9ca3af; margin-top: 2px; }
#popover .pop-leave {
  font-size: 12px;
  font-weight: 600;
  color: #059669;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 10px;
}

.jira-link {
  color: #4E79A7;
  text-decoration: none;
  font-weight: 600;
}
.jira-link:hover { text-decoration: underline; }

#legend-popover {
  position: fixed;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
  padding: 12px 14px;
  min-width: 220px;
  max-width: 320px;
  z-index: 1000;
  display: none;
  font-size: 12px;
}
#legend-popover.visible { display: block; }
#legend-popover .legend-pop-id {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 4px;
}
#legend-popover .legend-pop-summary {
  font-size: 13px;
  color: #1a1a2e;
  margin-bottom: 6px;
}
#legend-popover .legend-pop-hours {
  font-size: 11px;
  color: #4E79A7;
  font-weight: 600;
}

/* Stack bar + pie vertically on narrow screens */
@media (max-width: 900px) {
  .chart-row { flex-direction: column; }
  .chart-box-pie { flex: none !important; width: 100% !important; }
  .split-item .chart-row > div[style] { flex: none !important; width: 100% !important; }
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-box img { display: block; margin: 0 auto 8px; }

.login-title {
  font-family: "Poppins", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #828e9d;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 13px;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  text-align: left;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box input[type="email"],
.login-box input[type="password"] {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  background: #fff;
  color: #1a1a2e;
  width: 100%;
}

.login-box input:focus {
  outline: none;
  border-color: #4E79A7;
  box-shadow: 0 0 0 3px rgba(78,121,167,.15);
}

.login-box button[type="submit"] {
  background: #4E79A7;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.login-box button[type="submit"]:hover { background: #3d6185; }

/* ── Header user / logout ───────────────────────────────────────────────── */
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
}

.logout-link {
  color: #6b7280;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  transition: background .1s;
}

.logout-link:hover { background: #f3f4f6; }

/* ── Auth bar ────────────────────────────────────────────────────────────── */
#auth-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 12px;
}

#auth-bar-inner {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

#refresh-controls {
  display: flex;
  gap: 8px;
}

.auth-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.auth-badge-ok {
  color: #059669;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.auth-badge-warn {
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.auth-badge-warn:hover { background: #fef3c7; }

.refresh-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s;
}

.refresh-btn:hover:not(:disabled) { background: #f3f4f6; }
.refresh-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.refresh-btn-all { color: #4E79A7; border-color: #93c5fd; }

.range-preset {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

.progress-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.progress-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 320px;
  max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.progress-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
  color: #111827;
}

.progress-label {
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 12px;
  min-height: 18px;
}

.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: #4E79A7;
  transition: width .25s ease;
}

.progress-count {
  font-size: 12px;
  color: #6b7280;
  text-align: right;
}

.progress-error {
  font-size: 13px;
  color: #b91c1c;
  margin: 10px 0 14px;
}

.progress-close {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

/* ── Non-admin table ─────────────────────────────────────────────────────── */
.worklog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.worklog-table th {
  background: #f9fafb;
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.worklog-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: #1a1a2e;
}

.worklog-table .date-header-row td {
  background: #f9fafb;
  padding: 6px 14px;
  font-size: 12px;
  color: #374151;
}

.worklog-table .issue-id { color: #4E79A7; font-weight: 500; white-space: nowrap; }
.worklog-table .epic-id { color: #6b7280; font-size: 12px; }

.empty-msg {
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

/* ── Compact layout for mobile */
@media (max-width: 640px) {
  .page { padding: 16px 12px; }
  .page-header { margin-bottom: 24px; padding-bottom: 20px; }

  .toolbar { flex-direction: column; width: 100%; }

  #filter-form { flex-direction: column; align-items: stretch; }
  #filter-form input[type="text"] { width: 100%; }
  #filter-form button { width: 100%; }
  .csv-btn { width: 100%; justify-content: center; }

  .view-toggle { width: 100%; }
  .view-toggle button { flex: 1; }

  .cards { gap: 8px; }
  .card { min-width: 0; flex: 1 1 calc(50% - 4px); }

  .chart-box { padding: 14px 10px; }
  .split-item { padding: 14px 10px; }

  #popover {
    position: fixed;
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    top: auto !important;
    max-width: none;
    max-height: 50vh;
    overflow-y: auto;
  }
}
