:root {
  --bg:              #EFEFEF;
  --card-bg:         #FFFFFF;
  --card-border:     #DDDDDD;
  --text-primary:    #2D2D2D;
  --text-secondary:  #646263;
  --text-muted:      #9D9D9D;
  --accent:          #144A50;
  --accent2:         #339288;
  --input-bg:        #FAFAFA;
  --input-border:    #B5B5B5;
  --input-focus:     #144A50;
  --btn-gradient:    linear-gradient(135deg, #063D40 0%, #005C4D 55%, #027779 100%);
  --btn-hover-op:    0.86;
  --row-req-bg:      #DDDDDD;
  --row-req-txt:     #2D2D2D;
  --row-fisc-bg:     #D1EAED;
  --row-fisc-txt:    #144A50;
  --row-today-bg:    #D6F0DC;
  --row-today-txt:   #012605;
  --badge-ok-bg:     #DAF2D0;
  --badge-ok-txt:    #012605;
  --badge-warn-bg:   #FFF8E1;
  --badge-warn-txt:  #B45300;
  --badge-late-bg:   #FFEBEE;
  --badge-late-txt:  #AF1717;
  --notice-bg:       #FFFFFF;
  --notice-txt:      #5d4037;
  --notice-border:   #f9a825;
  --hdr-from:        #002328;
  --hdr-to:          #00434D;
  --footer-txt:      #9D9D9D;
  --shadow:          0 2px 12px rgba(0, 53, 61, 0.09);
  --shadow-card:     0 4px 24px rgba(0, 53, 61, 0.10);
  --shadow-hdr:      0 4px 20px rgba(0, 0, 0, 0.18);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:              #001D21;
  --card-bg:         #002328;
  --card-border:     #00434D;
  --text-primary:    #FAFAFA;
  --text-secondary:  #C1C1C1;
  --text-muted:      #82A4A9;
  --accent:          #339288;
  --accent2:         #04D9C2;
  --input-bg:        #001D21;
  --input-border:    #00434D;
  --input-focus:     #339288;
  --btn-gradient:    linear-gradient(135deg, #005C4D 0%, #027779 100%);
  --btn-hover-op:    0.82;
  --row-req-bg:      #00434D;
  --row-req-txt:     #C1C1C1;
  --row-fisc-bg:     #173D42;
  --row-fisc-txt:    #ADC6C6;
  --row-today-bg:    #002B22;
  --row-today-txt:   #51B0A6;
  --badge-ok-bg:     #002B22;
  --badge-ok-txt:    #04D9C2;
  --badge-warn-bg:   #2D1700;
  --badge-warn-txt:  #FFB74D;
  --badge-late-bg:   #2D0000;
  --badge-late-txt:  #FF8989;
  --notice-bg:       #002328;
  --notice-txt:      #C1C1C1;
  --notice-border:   #f9a825;
  --hdr-from:        #001D21;
  --hdr-to:          #002328;
  --footer-txt:      #82A4A9;
  --shadow:          0 2px 14px rgba(0, 0, 0, 0.45);
  --shadow-card:     0 4px 28px rgba(0, 0, 0, 0.50);
  --shadow-hdr:      0 4px 20px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background 0.28s, color 0.28s;
}

.fullscreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.fullscreen--gradient {
  background: linear-gradient(160deg, #002328 0%, #00434D 100%);
}

.fullscreen-logo {
  height: 48px;
  width: auto;
  display: block;
  margin: 0 auto 28px;
}

.loading-inner { text-align: center; }

.loading-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}

.loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  animation: dot-pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(0.65); opacity: 0.4; }
  40%            { transform: scale(1);    opacity: 1;   }
}

.loading-text {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
}

.login-box {
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.login-box__logo { margin-bottom: 32px; }

.login-box__title {
  font-size: 1rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.4;
  margin-bottom: 8px;
}

.login-box__sub {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.03em;
}

.login-box__divider {
  width: 40px;
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  margin: 28px auto;
}

.ms-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.10);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  border-radius: 30px;
  color: #FFFFFF;
  font-family: Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.ms-btn:hover  { background: rgba(255, 255, 255, 0.20); border-color: rgba(255, 255, 255, 0.45); }
.ms-btn:active { transform: scale(0.985); }

.header {
  background: linear-gradient(160deg, var(--hdr-from) 0%, var(--hdr-to) 100%);
  box-shadow: var(--shadow-hdr);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  flex: 1;
}

.logo-img {
  height: 40px;
  width: auto;
  flex-shrink: 0;
}

.header-titles { min-width: 0; }

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-sub {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.52);
  margin-top: 3px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.10);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  padding: 7px 16px;
  color: rgba(255, 255, 255, 0.85);
  font-family: Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.logout-btn:hover { background: rgba(255, 255, 255, 0.22); }

.theme-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.10);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  padding: 7px 15px;
  color: #FFFFFF;
  font-family: Arial, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.theme-btn:hover { background: rgba(255, 255, 255, 0.18); }
.theme-btn .icon { font-size: 0.9rem; line-height: 1; }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 32px 48px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 28px;
  align-items: start;
}

.grid-col {
  display: flex;
  flex-direction: column;
}

.section-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
  padding-left: 2px;
}

.section-label--result { margin-bottom: 14px; }

.card {
  background: var(--card-bg);
  border-radius: 18px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-card);
  padding: 28px;
  margin-bottom: 20px;
  transition: background 0.28s, border-color 0.28s;
}

.form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 10px;
}

.date-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--input-border);
  border-radius: 10px;
  font-family: Arial, sans-serif;
  font-size: 1.05rem;
  color: var(--text-primary);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.18s, background 0.28s;
}

.date-input:focus {
  border-color: var(--input-focus);
  background: var(--card-bg);
}

.date-input.invalid { border-color: #AF1717; }

.error-msg {
  display: none;
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #AF1717;
}

.calc-btn {
  display: block;
  width: 100%;
  padding: 15px;
  margin-top: 16px;
  background: var(--btn-gradient);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: opacity 0.18s, transform 0.1s;
}

.calc-btn:hover  { opacity: var(--btn-hover-op); }
.calc-btn:active { transform: scale(0.985); }

.result-card         { display: none; }
.result-card.visible { display: block; }

.result-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 10px;
  gap: 12px;
}

.rr-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 0;
}

.rr-value {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.row-lim-req  { background: var(--row-req-bg);   color: var(--row-req-txt);   }
.row-lim-fisc { background: var(--row-fisc-bg);  color: var(--row-fisc-txt);  }
.row-hoje     { background: var(--row-today-bg); color: var(--row-today-txt); }

.status-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 20px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
  margin-top: 6px;
}

.badge-ok   { background: var(--badge-ok-bg);   color: var(--badge-ok-txt);   }
.badge-warn { background: var(--badge-warn-bg);  color: var(--badge-warn-txt); }
.badge-late { background: var(--badge-late-bg);  color: var(--badge-late-txt); }

.badge-days {
  font-size: 0.76rem;
  font-weight: 600;
  opacity: 0.8;
  letter-spacing: 0.02em;
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: transparent;
  color: inherit;
  font-family: Arial, sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  padding: 0;
  margin-left: 5px;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.help-btn:hover,
.help-btn:focus-visible { opacity: 1; outline: none; }

.tooltip-box {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: #1C1C1E;
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.52;
  padding: 10px 12px;
  border-radius: 8px;
  text-transform: none;
  letter-spacing: 0.01em;
  white-space: normal;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.17s, visibility 0.17s;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.tooltip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1C1C1E;
}

.tooltip-wrap:hover .tooltip-box,
.help-btn:focus-visible + .tooltip-box,
.tooltip-wrap.active .tooltip-box {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.venc-note {
  margin-top: 12px;
  font-size: 0.73rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.chamado-wrap         { display: none; margin-top: 14px; }
.chamado-wrap.visible { display: block; }

.chamado-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.chamado-divider span {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--badge-late-txt);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.chamado-divider::before,
.chamado-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--badge-late-txt);
  opacity: 0.3;
}

.chamado-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  background: transparent;
  border: 2px solid var(--badge-late-txt);
  border-radius: 10px;
  color: var(--badge-late-txt);
  font-family: Arial, sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  letter-spacing: 0.02em;
}

.chamado-btn:hover {
  background: var(--badge-late-txt);
  color: #fff;
}

.chamado-btn svg { flex-shrink: 0; }

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--notice-bg);
  border-radius: 14px;
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--notice-border);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 20px;
  transition: background 0.28s;
}

.notice-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.notice-text {
  font-size: 0.82rem;
  color: var(--notice-txt);
  line-height: 1.58;
  font-weight: 500;
}

.info-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.info-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent2);
  flex-shrink: 0;
}

.footer {
  text-align: center;
  padding-top: 12px;
  font-size: 0.68rem;
  color: var(--footer-txt);
  line-height: 1.7;
}

.footer strong { color: var(--accent2); }

@media (max-width: 1023px) {
  .header-inner { padding: 14px 24px; }
  .container { padding: 28px 24px 40px; }
  .main-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
  .header-sub { display: none; }
}

@media (max-width: 767px) {
  .header-inner {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .header-brand { gap: 12px; }

  .logo-img { height: 34px; }

  .header-title { font-size: 0.9rem; white-space: normal; }

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

  .user-name { max-width: 120px; }

  .container { padding: 20px 16px 36px; }

  .main-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .card { padding: 22px; border-radius: 16px; }

  .status-badge { padding: 18px 14px; font-size: 0.92rem; }

  .rr-value { font-size: 0.95rem; }
}

@media (max-width: 479px) {
  .header-title { font-size: 0.85rem; }
  .logout-btn, .theme-btn { padding: 6px 12px; font-size: 0.75rem; }
  .card { padding: 18px; }
  .date-input { font-size: 0.95rem; padding: 12px 14px; }
  .calc-btn { padding: 14px; font-size: 0.95rem; }
}
