:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #fffaf3;
  --surface-2: #ffffff;
  --ink: #1f2933;
  --muted: #65727f;
  --line: #ded7cc;
  --teal: #0f766e;
  --teal-2: #e3f3f0;
  --wine: #8b1e3f;
  --wine-2: #f5e7ec;
  --gold: #c98316;
  --gold-2: #fff2d8;
  --green: #2f7d32;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 14px 32px rgba(31, 41, 51, 0.1);
  --radius: 8px;
  --sidebar: 280px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(210deg, rgba(139, 30, 63, 0.08), transparent 32%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
}

.sprite {
  display: none;
}

.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #163330;
  color: #f9faf8;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.1;
}

.brand span {
  display: block;
  color: #bdd9d5;
  font-size: 0.8rem;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dcecea;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  color: #c8dedb;
  font-size: 0.86rem;
}

.user-pill {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f9bf45;
  color: #2c2518;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: rgba(247, 244, 238, 0.9);
  border-bottom: 1px solid rgba(222, 215, 204, 0.8);
  backdrop-filter: blur(12px);
}

.mobile-menu {
  display: none;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.content {
  padding: 22px clamp(16px, 3vw, 34px) 42px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.72fr);
}

.login-visual {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 100vh;
  padding: clamp(28px, 6vw, 70px);
  background:
    linear-gradient(rgba(22, 51, 48, 0.1), rgba(22, 51, 48, 0.74)),
    url("../assets/casa-symbol.svg") center 28% / min(380px, 58vw) no-repeat,
    #163330;
  color: #ffffff;
  overflow: hidden;
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(249, 191, 69, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(249, 191, 69, 0.1) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, transparent, black 42%, black);
}

.login-copy {
  position: relative;
  max-width: 720px;
}

.login-copy h1 {
  margin: 0 0 14px;
  font-size: clamp(2.4rem, 6vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-copy p {
  margin: 0;
  max-width: 620px;
  color: #e3f3f0;
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.6;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  align-content: center;
  padding: clamp(22px, 4vw, 48px);
  background: var(--surface);
}

.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.login-card > p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.55;
}

.demo-access {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0 0 5px;
  font-size: 1.35rem;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.metric-card,
.panel,
.table-card,
.timeline-item,
.notice-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.92);
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.06);
}

.metric-card {
  padding: 18px;
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 16px;
}

.metric-card .label {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-card .value {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1;
  font-weight: 800;
}

.metric-card .hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.panel {
  padding: 18px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-box {
  min-width: min(100%, 320px);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 12px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  min-height: 42px;
  background: transparent;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  text-decoration: none;
  font-weight: 700;
}

.btn:hover {
  border-color: #b8aea0;
}

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.btn.wine {
  background: var(--wine);
  border-color: var(--wine);
  color: #ffffff;
}

.btn.ghost {
  background: transparent;
}

.btn.icon-only {
  width: 40px;
  padding: 0;
}

.btn.danger {
  color: #ffffff;
  background: var(--red);
  border-color: var(--red);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 700;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: #ffffff;
  background: var(--teal);
}

.table-card {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fbf7ef;
}

td {
  font-size: 0.92rem;
}

tbody tr:hover {
  background: rgba(15, 118, 110, 0.04);
}

.cell-main {
  display: grid;
  gap: 3px;
}

.cell-main strong {
  font-size: 0.96rem;
}

.cell-main span {
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.green {
  color: #14532d;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.badge.gold {
  color: #7a4b00;
  background: var(--gold-2);
  border-color: #f8d388;
}

.badge.red {
  color: #7f1d1d;
  background: #fee2e2;
  border-color: #fecaca;
}

.badge.teal {
  color: #134e4a;
  background: var(--teal-2);
  border-color: #99d8d0;
}

.badge.wine {
  color: var(--wine);
  background: var(--wine-2);
  border-color: #e4b8c5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #394651;
  font-weight: 800;
  font-size: 0.85rem;
}

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

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 700;
}

.inline-check input {
  width: 18px;
  height: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(980px, 100%);
  max-height: min(90vh, 860px);
  overflow: auto;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
}

.modal-body {
  padding: 18px;
}

.modal-actions,
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item,
.notice-item {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.timeline-item header,
.notice-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.timeline-item p,
.notice-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(86px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.day-cell {
  min-height: 112px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.day-cell strong {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.day-event {
  display: block;
  padding: 6px;
  border-radius: 7px;
  background: var(--teal-2);
  color: #134e4a;
  font-size: 0.76rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.finance-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.amount.good {
  color: var(--green);
}

.amount.bad {
  color: var(--red);
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: #163330;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.small-text {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.kpi-strip {
  display: grid;
  gap: 8px;
}

.kpi-strip div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.kpi-strip div:last-child {
  border-bottom: 0;
}

.danger-zone {
  border-color: #fecaca;
  background: #fff7f7;
}

@media (max-width: 1120px) {
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 320px);
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  body.menu-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 15;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .login-page {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 48vh;
  }

  .login-panel {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .content {
    padding-bottom: 28px;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .finance-summary {
    grid-template-columns: 1fr;
  }

  .page-head,
  .topbar {
    align-items: stretch;
  }

  .page-head,
  .toolbar {
    flex-direction: column;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .topbar .status-line {
    grid-column: 1 / -1;
  }

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

  .demo-access {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }

  .btn.icon-only,
  .mobile-menu {
    width: 40px;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }
}
