:root {
  --bg-gray: #d4d4d4;
  --card-bg: #ffffff;
  --line-gray: #bbbbbb;
  --text-main: #000000;
  --text-sec: #555555;
  --btn-bg: #e4e4e4;
  --btn-bg-hover: #d4d4d4;
  --btn-border: #c7c7c7;
  --shadow-soft: 0 20px 40px rgba(0, 0, 0, 0.08);
  --radius-card: 24px;
  --radius-btn: 999px;
  --transition-fast: 0.35s ease;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-gray);
  color: var(--text-main);
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  font-size: 15px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: none;
  margin: auto;
  padding: 10px 14px 14px;
  gap: 10px;
}

/* header */
header.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  gap: 10px;
  flex-wrap: wrap;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.logo-box {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: #f1f1f1;
  border: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.logo-box img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  display: block;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.brand-subtitle {
  font-size: 12px;
  color: var(--text-sec);
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-gray);
  background: rgba(250, 250, 250, 0.9);
  flex-wrap: wrap;
}

.date-pill {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 4px;
}
.date-pill span {
  font-size: 11px;
  color: var(--text-sec);
  line-height: 1;
}
.date-pill input[type="date"] {
  min-width: 150px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  padding: 0 10px;
  background: #fff;
  font-size: 14px;
}

button {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  background: var(--btn-bg);
  color: var(--text-main);
  border: 1px solid var(--btn-border);
  transition: background var(--transition-fast), transform 0.1s ease, box-shadow 0.1s ease;
  min-height: 40px;
}
button.primary {
  background: linear-gradient(135deg, #ffffff, #e5e5e5);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}
button.secondary {
  background: #f5f5f5;
}
button:active {
  transform: scale(0.97);
  box-shadow: none;
}
@media (hover: hover) {
  button:hover {
    background: var(--btn-bg-hover);
  }
}

.icon-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  background: #f5f5f5;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  background: #f5f5f5;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* main */
main.app-main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  border-radius: 28px;
  background: radial-gradient(circle at top left, #f8f8f8, #e0e0e0);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 12px;
  min-height: 0;
}

.panel {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  border: 1px solid #f0f0f0;
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.panel-sub {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--text-sec);
}

.status-message {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-sec);
  text-align: right;
  min-height: 18px;
}
.status-message.ok {
  color: #0b7a3a;
}
.status-message.warn {
  color: #8a5b00;
}
.status-message.bad {
  color: #9b1c1c;
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.tag {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-gray);
  background: #fafafa;
}
.tag.alt {
  background: #f0f0f0;
  border-style: dashed;
}

/* form */
.form {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0px 5px;

  /* scrollbar discreta */
  scrollbar-width: thin;
}
.form::-webkit-scrollbar {
  width: 10px;
}
.form::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 999px;
}
.form::-webkit-scrollbar-track {
  background: transparent;
}

.field label {
  display: block;
  font-size: 11px;
  color: var(--text-sec);
  margin-bottom: 4px;
}
.label-hint {
  font-size: 11px;
  color: var(--text-sec);
  font-weight: 400;
  margin-left: 4px;
}

.field input,
.field select {
  width: 100%;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  background: #fff;
  padding: 0 12px;
  font-size: 13px;
}

textarea {
  width: 100%;
  min-height: 58px;
  max-height: 84px;
  resize: none;
  border-radius: 18px;
  border: 1px solid var(--btn-border);
  background: #fff;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.25;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  margin: 2px 0;
}

.roomCards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.roomCard.wide {
  grid-column: 1 / -1;
}

.roomCard {
  padding: 10px 10px;
  border-radius: 18px;
  background: #f6f6f6;
  border: 1px solid var(--line-gray);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  align-items: center;
  text-align: center;
}
.roomCard .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.roomCard .name {
  font-size: 13px;
  font-weight: 650;
}
.roomCard .badge {
  font-size: 11px;
  color: var(--text-sec);
  border: 1px solid var(--btn-border);
  background: #fff;
  padding: 3px 8px;
  border-radius: 999px;
}
.roomCard .sub {
  font-size: 12px;
  color: var(--text-sec);
}
.roomCard.selected {
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1);
  border-color: #9a9a9a;
}

.form-footer {
  padding-top: 4px;
  padding-bottom: 4px;
  display: flex;
  flex-direction: column;
}

/* ações */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.actions button {
  flex: 1 1 120px;
}

.tiny-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-sec);
}

/* grid */
.grid-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line-gray);
  background: #fafafa;
}

.daygrid {
  --rows: 24;
  --row-h: 18px;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 62px repeat(var(--room-cols, 4), minmax(0, 1fr));
  background: transparent;
  min-width: 520px;
}

.headercell {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}
.headercell.left {
  justify-content: flex-start;
  padding-left: 10px;
  font-size: 12px;
  color: var(--text-sec);
}

.timecol,
.roomcol {
  position: relative;
  min-height: calc(var(--rows) * var(--row-h));
  background: transparent;
}

.gridcell {
  height: var(--row-h);
  border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
}
.gridcell.hour {
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
}

.time-label {
  position: absolute;
  left: 10px;
  transform: translateY(-8px);
  font-size: 11px;
  color: var(--text-sec);
  pointer-events: none;
}

/* bloco */
.block {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #fff;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.1);
  padding: 8px 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 50px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.block:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
  z-index: 10;
}
.block.alt {
  background: #f3f3f3;
  border-style: dashed;
}

.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  max-height: 20px;
  flex-shrink: 0;
}

.room {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.line {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
  flex-shrink: 0;
  height: 14px;
}

.desc-preview {
  font-size: 10px;
  color: var(--text-sec);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  margin-top: 2px;
}

.trash {
  min-width: 20px;
  min-height: 20px;
  padding: 1px 1px;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  background: #f5f5f5;
  font-size: 13px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s ease;
}
@media (hover: hover) {
  .trash:hover {
    background: var(--btn-bg-hover);
  }
}

/* modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.hidden {
  display: none;
}

.modal-card {
  width: min(1300px, 96vw);
  max-height: min(82vh, 740px);
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  border: 1px solid #f0f0f0;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
}
.modal-title {
  font-size: 18px;
  font-weight: 650;
}
.modal-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-sec);
}

.audit {
  padding: 14px 18px;
  overflow: auto;
  max-height: calc(82vh - 90px);
}
.audit-item {
  border-radius: 18px;
  border: 1px solid var(--line-gray);
  background: #fafafa;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.audit-item .row1 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}
.audit-item .meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-sec);
  white-space: pre-wrap;
}

.detail-body {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-line {
  font-size: 14px;
  color: var(--text-main);
}
.detail-desc {
  margin-top: 6px;
  border-radius: 18px;
  border: 1px solid var(--line-gray);
  background: #fafafa;
  padding: 12px 12px;
}
.detail-desc-title {
  font-size: 12px;
  color: var(--text-sec);
  font-weight: 700;
  margin-bottom: 6px;
}
.detail-desc-text {
  font-size: 14px;
  color: var(--text-main);
  white-space: pre-wrap;
  user-select: text;
}

@media (max-width: 1100px) {
  .page {
    grid-template-columns: 360px 1fr;
  }
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }
  body {
    user-select: text;
  }
  .app {
    height: auto;
    min-height: 100vh;
  }
  main.app-main {
    overflow: visible;
  }
  .page {
    position: static;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  header.app-header {
    border-radius: 18px;
    flex-direction: column;
    align-items: flex-start;
  }

  .app-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .nav-pill {
    width: 100%;
    justify-content: space-between;
  }

  .date-pill {
    flex: 1;
  }
  .date-pill input[type="date"] {
    min-width: 0;
    width: 100%;
  }

  .row2 {
    grid-template-columns: 1fr;
  }

  .roomCards {
    grid-template-columns: 1fr;
  }

  .modal-card {
    max-height: 90vh;
  }

  .block .line {
    margin-top: 0;
    padding-top: 0;
  }

  .block .line[title]:hover {
    cursor: help;
  }
}

/* MODAL TRASH */
.modal-card-small {
  width: min(420px, 96vw);
  max-height: none;
}

.confirm-actions {
  padding: 12px 18px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #ffffff;
}

button.primary.danger {
  background: linear-gradient(135deg, #ff5858, #f09819);
  color: #ffffff;
}
@media (hover: hover) {
  button.primary.danger:hover {
    background: linear-gradient(135deg, #ff6b6b, #ffb347);
  }
}
