:root {
  color-scheme: dark;
  --bg: #15171c;
  --surface: #20242b;
  --surface-soft: #282d36;
  --surface-elevated: #303744;
  --ink: #f5f7fb;
  --muted: #c0c7d2;
  --muted-soft: #8f98a7;
  --line: rgba(244, 247, 251, 0.16);
  --accent: #c97a5a;
  --accent-soft: rgba(201, 122, 90, 0.14);
  --accent-border: rgba(201, 122, 90, 0.55);
  --success: #8bd3a6;
  --info: #9ab8ff;
  --amber: #e2bb66;
  --red: #e17676;
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.035));
  --field-bg: rgba(255, 255, 255, 0.055);
  --field-hover-bg: rgba(255, 255, 255, 0.08);
  --button-bg: rgba(255, 255, 255, 0.052);
  --button-hover-bg: rgba(255, 255, 255, 0.088);
  --page-bg:
    radial-gradient(circle at top left, rgba(201, 122, 90, 0.11), transparent 32rem),
    linear-gradient(180deg, #1a1d23 0%, #15171c 56%, #12151a 100%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--ink);
  font: 13px/1.45 "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  font-weight: 700;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--button-hover-bg);
  transform: translateY(-1px);
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button svg,
.run-state svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex: 0 0 auto;
}

#shareWhatsApp svg {
  fill: currentColor;
  stroke: none;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 7px clamp(12px, 2vw, 24px) 6px;
  border-bottom: 1px solid var(--line);
  background: rgba(28, 31, 38, 0.92);
  backdrop-filter: blur(12px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  justify-self: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar .title-block {
  text-align: left;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(15px, 1.35vw, 18px);
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 800;
  white-space: nowrap;
}

.eyebrow,
.title-meta {
  display: block;
  margin: 0;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.title-meta {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(56vw, 560px);
}

.top-button,
.run-state {
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
  background: var(--button-bg);
  border: 1px solid var(--line);
  color: var(--muted);
}

.notification-menu-button[aria-expanded="true"] {
  color: var(--ink);
  border-color: rgba(154, 184, 255, 0.38);
  background: rgba(154, 184, 255, 0.14);
}

.run-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.run-state[data-state="ok"] {
  color: var(--ink);
  border-color: rgba(139, 211, 166, 0.42);
  background: rgba(139, 211, 166, 0.14);
}

.run-state[data-state="warn"] {
  color: var(--ink);
  border-color: rgba(226, 187, 102, 0.45);
  background: rgba(226, 187, 102, 0.16);
}

.run-state[data-state="error"] {
  color: var(--ink);
  border-color: rgba(225, 118, 118, 0.44);
  background: rgba(225, 118, 118, 0.14);
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px clamp(10px, 2vw, 20px) 32px;
  display: grid;
  gap: 13px;
}

.admin-panel,
.empty-page,
.control-band,
.notification-panel,
.day-overview,
.shift-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-bg);
}

.admin-panel {
  padding: 12px;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span,
.day-heading span,
.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.field input:hover,
.field select:hover {
  background: var(--field-hover-bg);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(201, 122, 90, 0.14);
}

.field select option {
  background: #f7f8fa;
  color: #101318;
}

.field select option:checked {
  background: #c9cbd0;
  color: #101318;
}

.file-field input {
  padding-top: 9px;
}

.primary-button {
  border-color: rgba(245, 247, 251, 0.72);
  background: var(--ink);
  color: #15171c;
}

.primary-button:hover:not(:disabled) {
  border-color: #ffffff;
  background: #ffffff;
  color: #101318;
}

.icon-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 8px;
}

.form-status {
  margin: 10px 0 0;
  color: var(--muted);
}

.title-meta.has-error,
.form-status.has-error {
  color: var(--red);
}

.title-meta.is-ok,
.form-status.is-ok {
  color: var(--success);
}

.empty-page {
  display: grid;
  gap: 6px;
  min-height: 150px;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.empty-page strong {
  display: block;
  font-size: 18px;
}

.empty-page span {
  color: var(--muted);
}

.workspace {
  display: grid;
  gap: 13px;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(180px, 0.9fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
}

.day-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.today-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 8px;
}

.notification-panel {
  position: fixed;
  top: 76px;
  right: 16px;
  left: auto;
  bottom: auto;
  z-index: 25;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
  padding: 14px;
  border-color: rgba(244, 247, 251, 0.24);
  background: linear-gradient(180deg, #292d35 0%, #20242b 100%);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.52);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity 180ms ease, transform 180ms ease;
}

.notification-backdrop {
  display: none;
}

body.notifications-open .notification-backdrop {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: block;
  background: rgba(8, 10, 14, 0.44);
}

body.notifications-open .notification-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.notification-panel-head,
.notification-heading,
.notification-next {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.notification-panel-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.close-notifications {
  display: inline-flex;
}

.notification-heading span,
.notification-next span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.notification-heading strong,
.notification-next strong {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-heading small {
  color: var(--muted-soft);
  font-size: 12px;
}

.notification-heading small.has-error {
  color: var(--red);
}

.notification-heading small.is-ok {
  color: var(--success);
}

.notification-toggle {
  min-height: 42px;
  border-radius: 8px;
}

.notification-chips {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.notification-chip {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border: 1px solid rgba(154, 184, 255, 0.18);
  border-radius: 999px;
  background: rgba(154, 184, 255, 0.10);
  color: #dce6ff;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.day-overview {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
  gap: 16px;
  padding: 14px 16px;
}

.day-heading {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
}

.day-heading strong {
  display: block;
  overflow: hidden;
  font-size: clamp(21px, 2.1vw, 30px);
  line-height: 1.1;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-heading small {
  color: var(--muted-soft);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-height: 70px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.15;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.shift-card {
  display: grid;
  gap: 13px;
  padding: 14px;
}

.shift-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.shift-card h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.2;
}

.shift-card .source {
  color: var(--muted-soft);
  font-size: 12px;
  white-space: nowrap;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.time-box {
  min-height: 68px;
  padding: 10px;
  border-right: 1px solid var(--line);
}

.time-box:last-child {
  border-right: 0;
}

.time-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.time-box strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.activity-list,
.segment-list {
  display: grid;
  gap: 7px;
}

.activity-list {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
}

.activity-pill {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 29px;
  border: 1px solid rgba(154, 184, 255, 0.18);
  border-radius: 999px;
  background: rgba(154, 184, 255, 0.12);
  color: #dce6ff;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.activity-pill.is-cx {
  border-color: rgba(139, 211, 166, 0.28);
  background: rgba(139, 211, 166, 0.16);
  color: #d8f7e2;
}

.activity-pill.is-pausa,
.activity-pill.is-refeicao {
  border-color: rgba(226, 187, 102, 0.30);
  background: rgba(226, 187, 102, 0.16);
  color: #ffe3a0;
}

.activity-pill.is-fecho {
  border-color: rgba(225, 118, 118, 0.30);
  background: rgba(225, 118, 118, 0.14);
  color: #ffd6d6;
}

.segment-list {
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

.segment-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: center;
}

.segment-time {
  color: var(--muted-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.no-results {
  grid-column: 1 / -1;
  min-height: 130px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .upload-form,
  .control-band,
  .notification-panel,
  .day-overview {
    grid-template-columns: 1fr;
  }

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

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(1),
  .metric:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: auto;
    padding: 9px 10px 10px;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .topbar .title-block,
  .top-actions {
    grid-column: 1;
  }

  .top-actions {
    width: 100%;
    justify-self: start;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .top-button,
  .run-state {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 10px;
    font-size: 12px;
    gap: 6px;
  }

  .notification-menu-button {
    width: 38px;
    min-width: 38px;
    padding: 0;
  }

  .notification-menu-button span {
    display: none;
  }

  .title-meta {
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
  }

  body.notifications-open .notification-backdrop {
    background: rgba(8, 10, 14, 0.68);
  }

  .notification-panel {
    right: 10px;
    bottom: max(12px, env(safe-area-inset-bottom));
    top: auto;
    left: 10px;
    width: auto;
    max-height: min(72vh, 560px);
    background: linear-gradient(180deg, #2b3039 0%, #222731 100%);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
    transform: translateY(calc(100% + 22px));
    transform-origin: bottom center;
  }

  body.notifications-open .notification-panel {
    transform: translateY(0);
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .time-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .time-box {
    min-height: 58px;
    padding: 8px 7px;
  }

  .time-box span {
    font-size: 10px;
  }

  .time-box strong {
    margin-top: 5px;
    font-size: 18px;
  }

  .upload-form button,
  .control-band button:not(.today-button),
  .notification-toggle {
    width: 100%;
  }
}
