:root {
  --bg: #edf1f3;
  --surface: #ffffff;
  --surface-soft: #f6f8f8;
  --ink: #172126;
  --muted: #657178;
  --line: #d7dfe1;
  --line-strong: #c4cfd2;
  --navy: #263b4a;
  --navy-soft: #e8eef1;
  --deep-red: #a72e43;
  --red: #d75a67;
  --soft-red: #f2b7b8;
  --amber: #efca69;
  --soft-green: #b8dcae;
  --green: #4d9f70;
  --blue: #39789a;
  --violet: #75568f;
  --shadow-sm: 0 1px 2px rgba(22, 33, 38, 0.06), 0 5px 18px rgba(22, 33, 38, 0.05);
  --shadow-md: 0 12px 34px rgba(22, 33, 38, 0.1);
  font-family: Inter, Manrope, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 1840px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
}

.top-panel,
.calendar-zone,
.info-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.top-panel {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  grid-template-areas:
    "brand form"
    "summary summary";
  margin-bottom: 12px;
  overflow: hidden;
}

.brand-block {
  grid-area: brand;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  background: var(--navy);
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-block .eyebrow {
  color: rgba(255, 255, 255, 0.66);
}

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

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.05;
}

.person-form {
  grid-area: form;
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) 140px 82px minmax(150px, 1.2fr);
  gap: 10px;
  align-items: end;
  min-width: 0;
  padding: 12px;
}

.calculate-button { align-self: end; min-height: 40px; border: 0; border-radius: 5px; background: var(--navy); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.print-button,.logout-button { position: fixed; bottom: 14px; z-index: 12; border: 1px solid var(--line-strong); border-radius: 5px; padding: 8px 10px; background: rgba(255,255,255,.92); color: var(--ink); font: 700 11px/1 var(--font); cursor: pointer; }.print-button { right: 14px; }.logout-button { right: 118px; }
.admin-link { position:fixed; right:188px; bottom:16px; z-index:12; color:var(--ink); font-size:11px; font-weight:800; text-decoration:none; }
@media print { .top-panel,.info-panel,.print-button,.logout-button,.tooltip { display:none !important; }.workspace { display:block; }.calendar-zone { border:0; box-shadow:none; }.calendar-grid { grid-template-columns:repeat(3,1fr); } }

label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

label span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:hover {
  border-color: #aab9bd;
  background: #fff;
}

input:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(57, 120, 154, 0.14);
}

.summary-grid {
  grid-area: summary;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 0;
  border-top: 1px solid var(--line);
  background: var(--line);
  gap: 1px;
}

.summary-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 9px;
  align-items: center;
  min-width: 0;
  min-height: 55px;
  padding: 8px 10px;
  background: var(--surface);
}

.summary-card span {
  grid-column: 2;
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.summary-card strong {
  grid-row: 1 / 3;
  display: block;
  min-width: 30px;
  font-size: 24px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.summary-card p {
  grid-column: 2;
  overflow: hidden;
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 27vw, 388px);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.calendar-zone {
  min-width: 0;
  padding: 12px;
}

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
  margin-bottom: 10px;
}

.calendar-toolbar h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.month-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 5px rgba(22, 33, 38, 0.05);
}

.month-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(23, 33, 38, 0.12);
}

.month-card.positive header {
  background: #e6f2e3;
}

.month-card.neutral header {
  background: #fbf2d5;
}

.month-card.negative header {
  background: #f8dddd;
}

.month-card h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.1;
}

.month-card header > span {
  max-width: 54%;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-meta {
  margin-top: 3px;
  border: 1px solid rgba(23, 33, 38, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: help;
  font-size: 9px;
  font-weight: 850;
  line-height: 1.35;
}

.weekday-row,
.month-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  border-bottom: 1px solid var(--line);
  background: var(--navy);
}

.weekday-row span {
  padding: 3px 0;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  font-size: 8px;
  font-weight: 850;
}

.month-days {
  gap: 1px;
  padding: 1px;
  background: #d9e0df;
}

.day-blank,
.day-cell {
  position: relative;
  width: 100%;
  height: clamp(36px, 3.25vw, 45px);
  min-width: 0;
}

.day-blank {
  background: #f1f4f3;
}

.day-cell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 14px;
  place-items: center;
  overflow: hidden;
  border: 0;
  padding: 2px;
  background: var(--day-bg, #eef2f1);
  color: var(--day-ink, #172126);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: filter 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.day-cell > strong {
  align-self: center;
  font-size: 14px;
  line-height: 1;
}

.weekday {
  position: absolute;
  left: 3px;
  top: 2px;
  color: currentColor;
  opacity: 0.58;
  font-size: 7px;
  font-weight: 850;
}

.day-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  height: 14px;
  gap: 1px;
  overflow: hidden;
  white-space: nowrap;
}

.day-icon,
.day-number {
  display: inline-grid;
  place-items: center;
  flex: 0 1 11px;
  width: 11px;
  min-width: 7px;
  height: 11px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
  color: color-mix(in srgb, var(--day-ink, #172126) 80%, transparent);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
}

.day-icon.moon {
  flex-basis: 13px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  font-size: 11px;
}

.day-icon.solar {
  background: color-mix(in srgb, #f7df74 72%, transparent);
}

.day-icon.lunar {
  background: color-mix(in srgb, #253239 68%, transparent);
  color: #fff;
}

.day-icon.mercury {
  background: color-mix(in srgb, var(--violet) 68%, transparent);
  color: #fff;
}

.day-number {
  flex: 0 1 11px;
  font-size: 8px;
}

.day-number.personal {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 38, 0.06);
}

.day-cell:hover,
.day-cell.selected {
  z-index: 2;
  filter: saturate(1.08) brightness(1.03);
  box-shadow: inset 0 0 0 2px #172126;
}

.day-cell.rating-unique {
  outline: 2px solid var(--day-outline, transparent);
  outline-offset: -2px;
}

.day-cell.rating-solar,
.day-cell.rating-lunar {
  font-weight: 850;
}

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

.deepRed,
.deepRed i,
.swatch.deepRed {
  background: var(--deep-red);
  color: #fff;
}

.red,
.red i,
.swatch.red {
  background: var(--red);
}

.softRed,
.softRed i,
.swatch.softRed {
  background: var(--soft-red);
}

.amber,
.amber i,
.swatch.amber {
  background: var(--amber);
}

.softGreen,
.softGreen i,
.swatch.softGreen {
  background: var(--soft-green);
}

.green,
.green i,
.swatch.green {
  background: var(--green);
  color: #fff;
}

.info-panel {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

.tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.tabs button {
  min-width: 0;
  min-height: 34px;
  overflow: hidden;
  border: 0;
  padding: 0 5px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs button:hover {
  background: var(--navy-soft);
  color: var(--ink);
}

.tabs button.active {
  position: relative;
  background: #fff;
  color: var(--ink);
}

.tabs button.active::after {
  position: absolute;
  right: 18%;
  bottom: 0;
  left: 18%;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--blue);
  content: "";
}

.info-content {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  scrollbar-color: #bac5c8 transparent;
  scrollbar-width: thin;
}

.info-section h2 {
  margin-bottom: 10px;
  font-size: 21px;
  line-height: 1.05;
}

.day-digits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.day-status-list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.day-digits span,
.status-row,
.meaning-card,
.event-list li,
.number-list article {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.day-digits span {
  padding: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.day-digits b {
  display: block;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  padding: 8px 9px;
  border-left-width: 4px;
}

.status-row span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
}

.status-row strong {
  display: block;
  margin-top: 1px;
  font-size: 14px;
  line-height: 1.15;
}

.status-row > b {
  align-self: start;
  border: 1px solid rgba(23, 33, 38, 0.08);
  border-radius: 4px;
  padding: 3px 5px;
  background: rgba(255, 255, 255, 0.74);
  font-size: 8px;
  text-transform: uppercase;
}

.status-row p {
  grid-column: 1 / -1;
  margin: 0;
  color: #5b666c;
  font-size: 10px;
  line-height: 1.3;
}

.status-positive,
.number-positive {
  border-color: rgba(77, 159, 112, 0.42);
  background: #e8f3e6;
}

.status-neutral,
.number-neutral {
  border-color: rgba(222, 176, 59, 0.48);
  background: #fbf3d9;
}

.status-negative,
.number-negative {
  border-color: rgba(199, 67, 82, 0.4);
  background: #f9e1e1;
}

.status-special {
  border-color: rgba(57, 69, 77, 0.5);
  background: #e5e9ea;
}

.status-solar {
  border-color: rgba(157, 113, 21, 0.62);
  background: #f5e8b8;
}

.status-lunar {
  border-color: rgba(42, 53, 60, 0.68);
  background: #dce2e4;
}

.meaning-card {
  padding: 11px;
  margin-bottom: 9px;
}

.meaning-card h3,
.number-list h3 {
  margin-bottom: 5px;
  font-size: 14px;
}

.meaning-card p {
  margin-bottom: 7px;
  font-size: 11px;
  line-height: 1.35;
}

.meaning-card p:last-child {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.location-warning {
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid rgba(199, 67, 82, 0.35);
  border-radius: 6px;
  background: #f9e4e4;
  color: #812536;
  font-size: 11px;
  font-weight: 700;
}

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

.event-list li {
  display: grid;
  gap: 3px;
  padding: 9px;
}

.event-list strong {
  font-size: 12px;
}

.event-list span,
.number-list span,
.number-list p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

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

.number-list article {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
}

.number-list b {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
}

.number-positive b {
  background: var(--green);
  color: #fff;
}

.number-neutral b {
  background: var(--amber);
}

.number-negative b {
  background: var(--red);
}

.moon-hero {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 11px;
  align-items: center;
  padding: 11px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--navy-soft);
}

.moon-hero > span {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 36px;
}

.moon-hero h3,
.moon-hero p {
  margin-bottom: 4px;
}

.sources {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.sources a {
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
}

.sources a:hover {
  text-decoration: underline;
}

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

.legend-list div {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

.swatch {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 5px;
}

.tooltip {
  position: fixed;
  z-index: 20;
  display: none;
  width: min(360px, calc(100vw - 20px));
  max-height: min(440px, calc(100vh - 20px));
  overflow: auto;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.tooltip.visible {
  display: grid;
  gap: 5px;
}

.tooltip strong {
  font-size: 13px;
}

.tooltip span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.input-error,
.empty-state {
  padding: 16px;
  color: var(--deep-red);
  font-weight: 800;
}

@media (min-width: 1580px) {
  .calendar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .day-blank,
  .day-cell {
    height: 42px;
  }
}

@media (max-width: 1120px) {
  .top-panel {
    grid-template-columns: 180px minmax(0, 1fr);
  }

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

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

  .info-panel {
    position: static;
    max-height: none;
  }

  .info-content {
    max-height: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 8px;
  }

  .top-panel {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "form"
      "summary";
    margin-bottom: 8px;
  }

  .brand-block {
    min-height: 68px;
    border-right: 0;
  }

  h1 {
    font-size: 20px;
  }

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

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

  .calendar-zone {
    padding: 8px;
  }

  .day-blank,
  .day-cell {
    height: clamp(38px, 6vw, 46px);
  }
}

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

  .person-form label:last-of-type {
    grid-column: 1 / -1;
  }

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

  .summary-card:last-child {
    grid-column: 1 / -1;
  }

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

  .day-blank,
  .day-cell {
    height: 47px;
  }

  .day-bottom {
    gap: 0;
  }

  .info-content {
    padding: 11px;
  }
}
