:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #1f2523;
  --muted: #66706c;
  --line: #deded8;
  --accent: #16756b;
  --accent-strong: #0f5e57;
  --warning: #b66a10;
  --danger: #b84747;
  --good: #2f7d4f;
  --soft-green: #e8f3ef;
  --soft-gold: #fff2db;
  --soft-red: #fdecea;
  --soft-blue: #eaf1f7;
  --shadow: 0 16px 40px rgba(31, 37, 35, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #202724;
  color: #f8faf6;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f1d389;
  color: #202724;
  font-weight: 800;
}

.brand strong,
.brand span,
.sidebar-footer span,
.sidebar-footer strong {
  display: block;
}

.brand span,
.sidebar-footer span {
  color: #bac5be;
  font-size: 13px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

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

.nav-item span {
  width: 20px;
  text-align: center;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-footer strong {
  margin-top: 4px;
  font-size: 14px;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.06;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.link-title {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 850;
  text-align: left;
}

.link-title:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

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

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

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

.primary-button,
.ghost-button,
.icon-button,
.small-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.small-button {
  min-height: 34px;
  padding: 0 11px;
  border-color: var(--line);
  background: #fbfbf8;
  color: #34413d;
  font-size: 12px;
}

.small-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: #f2f2ee;
  color: var(--ink);
  font-size: 24px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.filters label,
.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 117, 107, 0.12);
}

.content {
  display: grid;
  gap: 22px;
}

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

.metric-card,
.panel,
.client-card,
.project-card,
.payment-row,
.alert-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.panel {
  padding: 18px;
}

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

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

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

.stack {
  display: grid;
  gap: 12px;
}

.client-card,
.project-card,
.payment-row,
.alert-card {
  padding: 16px;
  box-shadow: none;
}

.client-card {
  display: grid;
  gap: 14px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.muted {
  color: var(--muted);
}

.chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip,
.status,
.payment-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.chip {
  background: #f0f0eb;
  color: #4f5955;
}

.status.todo {
  background: var(--soft-blue);
  color: #355f82;
}

.status.progress {
  background: var(--soft-gold);
  color: #83560b;
}

.status.done,
.payment-status.paid {
  background: var(--soft-green);
  color: var(--good);
}

.payment-status.pending {
  background: var(--soft-red);
  color: var(--danger);
}

.payment-status.deposit {
  background: var(--soft-gold);
  color: var(--warning);
}

.project-card {
  display: grid;
  gap: 14px;
}

.project-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecece6;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.checklist {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.check-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 3px 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.check-toggle:hover {
  color: var(--ink);
}

.check-dot {
  display: grid;
  place-items: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 1px solid #c9cec9;
  border-radius: 5px;
  color: white;
  font-size: 12px;
}

.check-dot.is-done {
  border-color: var(--accent);
  background: var(--accent);
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline-item {
  position: relative;
  padding: 14px 14px 14px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: #fbfbf8;
}

.timeline-item time {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.photo-strip {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.photo-thumb {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: linear-gradient(135deg, #dfe9e6, #f5e0a6);
  color: #46524e;
  font-weight: 900;
}

.progress-image {
  display: block;
  width: min(100%, 360px);
  max-height: 260px;
  object-fit: cover;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.detail-main {
  display: grid;
  gap: 14px;
}

.back-button {
  width: fit-content;
}

.detail-header,
.detail-meta,
.detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
}

.detail-header {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: white;
}

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

.detail-meta span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  color: var(--muted);
}

.detail-meta strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

.chat-panel {
  display: grid;
  gap: 12px;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fbfbf8;
}

.chat-message {
  display: flex;
}

.chat-bubble {
  width: min(620px, 100%);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 13px 14px;
  background: white;
}

.chat-bubble time {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
}

.chat-bubble small {
  display: block;
  color: var(--muted);
}

.chat-image {
  display: block;
  width: min(100%, 420px);
  max-height: 340px;
  object-fit: cover;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-side {
  display: grid;
  gap: 14px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.amount {
  font-weight: 850;
}

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

.calendar-day {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}

.calendar-day strong {
  display: block;
  margin-bottom: 8px;
}

.event-pill {
  display: block;
  margin-top: 6px;
  border-radius: 6px;
  padding: 5px 7px;
  background: var(--soft-green);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
}

.alert-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.alert-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--soft-gold);
  color: var(--warning);
  font-weight: 900;
}

.schema-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.schema-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fbfbf8;
}

.schema-item code {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-weight: 850;
}

.dialog {
  width: min(860px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
}

.dialog::backdrop {
  background: rgba(32, 39, 36, 0.42);
}

.dialog form {
  padding: 22px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions {
  margin: 18px 0 0;
  padding: 0;
}

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

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

.empty-state {
  padding: 28px;
  border: 1px dashed #c8ccc7;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.access-screen {
  min-height: min(680px, calc(100vh - 180px));
  display: grid;
  place-items: center;
  padding: 30px 0;
}

.access-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: white;
  box-shadow: var(--shadow);
}

.access-panel h2 {
  margin-bottom: 8px;
}

.access-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .metric-grid,
  .filters,
  .schema-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .three-column,
  .detail-layout {
    grid-template-columns: 1fr;
  }

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

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

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(54px, 1fr));
    overflow-x: auto;
  }

  .nav-item {
    justify-content: center;
    min-width: 84px;
    font-size: 13px;
  }

  .sidebar-footer {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .card-top {
    display: grid;
  }

  .top-actions,
  .search-box {
    width: 100%;
    justify-content: stretch;
  }

  .primary-button {
    width: 100%;
  }

  .filters,
  .metric-grid,
  .form-grid,
  .schema-list {
    grid-template-columns: 1fr;
  }

  .project-meta {
    grid-template-columns: 1fr;
  }

  .detail-meta {
    grid-template-columns: 1fr;
  }

  .payment-row {
    grid-template-columns: 1fr;
  }

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