:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-muted: #f0f3ef;
  --line: #dce1db;
  --line-strong: #c4ccc3;
  --ink: #26312d;
  --muted: #6b746f;
  --faint: #8b948f;
  --accent: #22735d;
  --accent-strong: #155f4b;
  --accent-soft: #dceee7;
  --gold: #bf7f18;
  --gold-soft: #fff0c8;
  --danger: #a74336;
  --coral: #bc5d4f;
  --shadow: 0 18px 54px rgba(32, 43, 38, 0.12);
  --radius: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(247, 248, 245, 0.82) 34%),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--accent-strong);
  font-weight: 800;
  line-height: 1;
}

.brand-name {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.15;
}

.brand-scope {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-layout {
  display: grid;
  gap: 22px;
  padding-top: 28px;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  line-height: 1.08;
}

h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
}

h2 {
  font-size: 24px;
  font-weight: 800;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  min-width: min(100%, 420px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.summary-strip div {
  display: grid;
  gap: 2px;
  min-height: 68px;
  padding: 12px 14px;
  border-left: 1px solid var(--line);
}

.summary-strip div:first-child {
  border-left: 0;
}

.summary-strip span {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.summary-strip small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

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

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--faint);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 115, 93, 0.12);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.segmented-control {
  display: inline-flex;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segment {
  min-width: 76px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.segment:first-child {
  border-left: 0;
}

.segment.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.sort-control select {
  min-width: 104px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
}

.status-banner {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--coral);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.restaurant-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: separate;
  border-spacing: 0;
}

.restaurant-table th,
.restaurant-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.restaurant-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.restaurant-table tbody tr:last-child td {
  border-bottom: 0;
}

.restaurant-table tbody tr:hover {
  background: #fbfcfa;
}

.restaurant-name {
  display: grid;
  gap: 5px;
  min-width: 230px;
}

.restaurant-name strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.restaurant-name span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.external-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.rating-summary {
  display: grid;
  gap: 3px;
  min-width: 116px;
}

.stars {
  display: inline-flex;
  gap: 1px;
  color: var(--gold);
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
}

.stars.is-muted {
  color: var(--line-strong);
}

.rating-summary small,
.posted-by,
.state-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.note-block {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.note-list {
  display: grid;
  gap: 6px;
}

.note-item {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.note-item.is-mine {
  border-color: rgba(34, 115, 93, 0.24);
  background: var(--accent-soft);
}

.note-author,
.note-empty,
.note-more {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.note-item p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.note-action {
  justify-self: start;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.note-action:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.personal-state {
  display: grid;
  gap: 8px;
  min-width: 256px;
}

.state-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-button,
.favorite-button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.primary-button {
  min-width: 120px;
  padding: 0 15px;
  background: var(--accent);
  color: #fff;
}

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

.secondary-button,
.ghost-button {
  min-width: 104px;
  padding: 0 13px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  min-width: 112px;
  padding: 0 13px;
  border-color: rgba(167, 67, 54, 0.26);
  background: #fff;
  color: var(--danger);
}

.danger-button:hover {
  background: #fbe8e4;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.toggle-button {
  width: 84px;
  padding: 0 10px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

.toggle-button.is-active {
  border-color: rgba(34, 115, 93, 0.28);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.favorite-button,
.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
}

.favorite-button.is-active {
  border-color: rgba(188, 93, 79, 0.32);
  background: #fbe8e4;
  color: var(--coral);
}

.icon-button:hover,
.favorite-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.button-icon {
  width: 16px;
  text-align: center;
  line-height: 1;
}

.star-input,
.rating-input {
  display: inline-flex;
  gap: 2px;
  min-height: 34px;
  align-items: center;
}

.star-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--line-strong);
  font-size: 19px;
  line-height: 1;
}

.star-button.is-active {
  color: var(--gold);
}

.star-button:hover {
  background: var(--gold-soft);
  color: var(--gold);
}

.restaurant-cards {
  display: none;
}

.restaurant-card {
  display: grid;
  gap: 13px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.restaurant-card-actions {
  display: grid;
  gap: 9px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 42px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
}

.empty-state p {
  margin: 0;
  font-weight: 750;
}

.side-dialog,
.compact-dialog {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(38, 49, 45, 0.26);
}

.side-dialog::backdrop,
.compact-dialog::backdrop {
  background: rgba(38, 49, 45, 0.28);
}

.dialog-panel {
  display: grid;
  gap: 18px;
  width: min(440px, calc(100% - 24px));
  min-height: 100%;
  margin-left: auto;
  padding: 24px;
  border: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-panel.compact {
  min-height: auto;
  margin: 10vh auto 0;
  border-radius: var(--radius);
}

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

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

.field > span,
.check-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.field input {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 108px;
  resize: vertical;
  padding: 11px 12px;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 115, 93, 0.12);
}

.inline-fields {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 750;
}

.auth-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.auth-button {
  width: 100%;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  box-shadow: var(--shadow);
}

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

input[readonly] {
  color: var(--muted);
  background: var(--surface-muted);
}

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

  .segmented-control,
  .sort-control {
    width: 100%;
  }

  .segment {
    flex: 1 1 0;
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 28px, 1180px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    display: grid;
    justify-items: end;
  }

  .page-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .summary-strip {
    width: 100%;
    min-width: 0;
  }

  .summary-strip div {
    min-height: 62px;
    padding: 11px 10px;
  }

  .table-wrap {
    display: none;
  }

  .restaurant-cards {
    display: grid;
    gap: 10px;
  }

  .primary-button {
    min-width: 112px;
  }

  .ghost-button {
    max-width: 150px;
  }

  .ghost-button span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .brand-scope {
    display: none;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    min-width: 0;
  }

  .page-head {
    padding-top: 4px;
  }

  .summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-strip div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .summary-strip div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .dialog-panel {
    width: 100%;
    padding: 20px;
  }

  .dialog-panel.compact {
    margin-top: 0;
    min-height: 100%;
    border-radius: 0;
  }
}
