:root {
  --bg: #fbf7f2;
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --subtle: #f7f3ed;
  --line: #e7ded5;
  --ink: #231f20;
  --muted: #756f6a;
  --soft: #a8a09a;
  --rose: #e9d3d0;
  --rose-text: #a84d62;
  --sage: #e4eee6;
  --sage-text: #3f7a55;
  --amber: #fff2cf;
  --amber-text: #866018;
  --danger: #b04454;
  --shadow: 0 18px 42px rgba(44, 36, 30, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
label[for] {
  cursor: pointer;
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.app-header,
.card,
.tabs,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.app-header {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(420px, 2.15fr) auto;
  gap: 22px;
  align-items: end;
  padding: 20px;
}

.brand-mark {
  color: var(--rose-text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  color: #1f1d1d;
  font-size: 25px;
  line-height: 1.12;
}

.brand-block p,
.section-header p,
.panel-note,
.seat-assignment span,
.table-view-head span,
.empty-state span,
.summary-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.brand-block p {
  margin-top: 6px;
}

.header-fields {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr;
  gap: 12px;
}

.header-actions,
.action-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.field span {
  color: var(--soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus {
  border-color: #dba1a9;
  box-shadow: 0 0 0 3px rgba(219, 161, 169, 0.22);
}

.btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 0 15px;
  color: #fff;
  background: #242122;
  font-size: 14px;
  font-weight: 750;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.outline {
  color: #514b47;
  background: #fff;
  border-color: var(--line);
}

.btn.ghost {
  color: #77706a;
  background: transparent;
}

.btn.ghost:hover {
  color: var(--rose-text);
  background: #f3ece8;
}

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

.summary-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
}

.summary-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 16px;
  background: var(--rose);
}

.summary-card.stone .summary-icon {
  background: #eeeae5;
}

.summary-card.sage .summary-icon,
.summary-card.ok .summary-icon {
  background: var(--sage);
}

.summary-card.warn {
  border-color: #ead49c;
}

.summary-card.warn .summary-icon {
  background: var(--amber);
}

.summary-card strong {
  display: block;
  font-size: 26px;
  line-height: 1;
}

.summary-card span {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding: 8px;
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
  min-height: 40px;
  border: 0;
  border-radius: 16px;
  padding: 0 16px;
  color: #625c57;
  background: transparent;
  font-weight: 750;
}

.tab.active {
  color: #fff;
  background: #242122;
  box-shadow: 0 8px 18px rgba(36, 33, 34, 0.13);
}

.main-panel {
  margin-top: 18px;
}

.main-panel > .card + .split-layout {
  margin-top: 18px;
}

.card {
  padding: 20px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 21px;
  line-height: 1.2;
}

.section-header p {
  margin-top: 6px;
}

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

.rows.compact {
  gap: 10px;
}

.edit-row,
.seat-assignment,
.table-view-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(247, 243, 237, 0.68);
}

.edit-row {
  display: grid;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.guest-row {
  grid-template-columns: 1.15fr 0.9fr 0.75fr 1.3fr auto;
}

.table-row {
  grid-template-columns: 1.1fr 1fr 0.65fr 0.76fr 0.76fr 0.78fr auto;
}

.rule-row {
  grid-template-columns: 0.9fr 1fr 1fr 1.3fr auto;
}

.seat-usage,
.metric {
  border-radius: 16px;
  background: #fff;
}

.seat-usage {
  min-height: 42px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.seat-usage strong {
  color: var(--ink);
}

.seat-usage span {
  display: block;
}

.panel-note {
  margin-top: 16px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
}

.seat-assignment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.seat-assignment strong {
  display: block;
  font-weight: 750;
}

.seat-assignment span {
  display: block;
  margin-top: 3px;
}

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

.table-view-card {
  padding: 16px;
}

.table-view-card.danger {
  border-color: #e4a5ae;
  background: #fff1f2;
}

.table-view-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.table-view-head strong {
  display: block;
}

.table-view-head b {
  display: grid;
  place-items: center;
  min-width: 38px;
  height: 30px;
  border-radius: 999px;
  background: #fff;
}

.guest-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.guest-tags span {
  border-radius: 999px;
  padding: 7px 11px;
  color: #514b47;
  background: #fff;
  font-size: 13px;
  box-shadow: 0 6px 14px rgba(44, 36, 30, 0.05);
}

.guest-tags em {
  color: var(--soft);
  font-size: 13px;
  font-style: normal;
}

.metrics {
  display: grid;
  gap: 14px;
}

.hall-layout-wrap {
  display: grid;
  gap: 14px;
}

.hall-canvas {
  position: relative;
  width: 100%;
  max-height: 620px;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid #d8ccc1;
  border-radius: 24px;
  background: #fffdfb;
}

.hall-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(168, 160, 154, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 160, 154, 0.16) 1px, transparent 1px);
  background-size: 32px 32px;
}

.layout-zone {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 38px;
  border: 1px dashed rgba(168, 160, 154, 0.9);
  border-radius: 18px;
  background: rgba(247, 243, 237, 0.72);
}

.layout-zone.overflow {
  border-color: rgba(176, 68, 84, 0.8);
  background: rgba(255, 241, 242, 0.88);
}

.layout-table {
  display: grid;
  place-items: center;
  min-width: 28px;
  min-height: 24px;
  border: 2px solid #242122;
  border-radius: 10px;
  background: #ffffff;
  color: #242122;
  text-align: center;
  box-shadow: 0 8px 18px rgba(44, 36, 30, 0.08);
}

.layout-table.round,
.layout-table.oval {
  border-radius: 999px;
}

.layout-table.square {
  border-radius: 8px;
}

.layout-table.head-table {
  border-color: var(--rose-text);
  color: var(--rose-text);
}

.layout-table span {
  max-width: 100%;
  overflow: hidden;
  padding: 3px 5px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.layout-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.layout-legend b {
  width: 18px;
  height: 12px;
  display: inline-block;
  border: 2px solid #242122;
  border-radius: 4px;
  background: #fff;
}

.layout-legend b.buffer {
  border: 1px dashed rgba(168, 160, 154, 0.9);
  background: rgba(247, 243, 237, 0.72);
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  font-size: 14px;
}

.metric span,
.meter-label {
  color: var(--muted);
}

.meter-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee8e1;
}

.meter div {
  height: 100%;
  border-radius: inherit;
  background: #242122;
}

.notice,
.warning {
  border-radius: 22px;
  background: var(--amber);
  color: var(--amber-text);
  padding: 14px;
  font-size: 14px;
  line-height: 1.45;
}

.warning {
  border: 1px solid #edd798;
}

.empty-state {
  border: 1px dashed #d6cbc1;
  border-radius: 24px;
  background: rgba(247, 243, 237, 0.55);
  padding: 26px;
  text-align: center;
}

.empty-state b {
  display: block;
  margin-bottom: 5px;
}

.print-report {
  display: none;
}

@media print {
  @page {
    margin: 14mm;
    size: A4;
  }

  body {
    background: #fff;
    color: #1f1d1d;
  }

  .page {
    display: none;
  }

  .print-report {
    display: block;
    font-family: Inter, Arial, sans-serif;
  }

  .print-cover {
    border-bottom: 2px solid #1f1d1d;
    padding-bottom: 18px;
    margin-bottom: 18px;
  }

  .print-cover p {
    color: #a84d62;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
  }

  .print-cover h1 {
    margin-top: 8px;
    font-size: 30px;
  }

  .print-cover span {
    display: block;
    margin-top: 6px;
    color: #756f6a;
    font-size: 12px;
  }

  .print-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
  }

  .print-summary div {
    border: 1px solid #d8ccc1;
    border-radius: 8px;
    padding: 10px;
  }

  .print-summary span {
    display: block;
    color: #756f6a;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }

  .print-summary strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
  }

  .print-section {
    break-inside: avoid;
    margin-top: 18px;
  }

  .print-section h2 {
    margin-bottom: 8px;
    font-size: 16px;
  }

  .print-section p,
  .print-section li {
    color: #3b3633;
    font-size: 12px;
    line-height: 1.45;
  }

  .print-section table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
  }

  .print-section th,
  .print-section td {
    border: 1px solid #d8ccc1;
    padding: 7px;
    text-align: left;
    vertical-align: top;
  }

  .print-section th {
    background: #f7f3ed;
  }
}

@media (max-width: 1000px) {
  .app-header,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .header-fields,
  .summary-grid,
  .table-view-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guest-row,
  .table-row,
  .rule-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1280px);
    padding-top: 10px;
  }

  .app-header,
  .card {
    border-radius: 20px;
    padding: 16px;
  }

  .header-fields,
  .summary-grid,
  .guest-row,
  .table-row,
  .rule-row,
  .table-view-grid,
  .seat-assignment {
    grid-template-columns: 1fr;
  }

  .section-header,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .btn,
  .header-actions .btn {
    width: 100%;
  }
}
