* {
  box-sizing: border-box;
}

:root {
  --navy: #07182e;
  --navy-2: #0d2745;
  --teal: #0f806f;
  --teal-dark: #0a6659;
  --ink: #111c31;
  --muted: #68758a;
  --line: #dfe6ee;
  --surface: #ffffff;
  --background: #f3f6f9;
  --danger: #b52b34;
  --success: #0f806f;
  --shadow: 0 18px 45px rgba(12, 32, 55, 0.09);
}

html {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: inherit;
}

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

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

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

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

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  font-weight: 800;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 50px;
  height: 46px;
  place-items: center;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
}

.brand-large strong {
  font-size: 22px;
}

.brand-light {
  color: #fff;
}

.brand-light small {
  color: rgba(255,255,255,.62);
}

.brand-light .brand-mark {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.12);
}

.eyebrow,
.panel-kicker {
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: .18s ease;
}

.button-primary {
  background: var(--teal);
  color: #fff;
}

.button-primary:hover {
  background: var(--teal-dark);
}

.button-secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.button-secondary:hover {
  border-color: #b8c4d0;
  background: #f9fbfc;
}

.button-ghost {
  width: 100%;
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: #fff;
}

.button-full {
  width: 100%;
}

.button:disabled {
  cursor: wait;
  opacity: .65;
}

.landing-page,
.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(15,128,111,.22), transparent 32rem),
    linear-gradient(145deg, var(--navy) 0%, var(--navy-2) 100%);
}

.landing-shell {
  width: min(100%, 760px);
}

.landing-card,
.auth-card {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 24px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 30px 85px rgba(0,0,0,.28);
}

.landing-card {
  padding: clamp(34px, 7vw, 72px);
}

.landing-card .brand {
  margin-bottom: 48px;
}

.landing-card h1 {
  max-width: 620px;
  margin: 12px 0 18px;
  font-size: clamp(42px, 8vw, 74px);
  line-height: .98;
  letter-spacing: -.055em;
}

.landing-card p {
  max-width: 610px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.auth-shell {
  width: min(100%, 460px);
}

.auth-card {
  padding: 34px;
}

.auth-heading {
  margin: 38px 0 27px;
}

.auth-heading h1 {
  margin: 8px 0;
  font-size: 38px;
  letter-spacing: -.045em;
}

.auth-heading p {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 18px;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  color: #2d394c;
  font-size: 12px;
  font-weight: 800;
}

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

.field input,
.field select,
.search-input {
  min-height: 47px;
  padding: 0 13px;
}

.field textarea {
  padding: 12px 13px;
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15,128,111,.11);
}

.form-message,
.save-status {
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.form-message.error,
.save-status.error {
  color: var(--danger);
}

.form-message.success,
.save-status.success {
  color: var(--success);
}

.app-page {
  background: var(--background);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  display: flex;
  width: 260px;
  flex-direction: column;
  padding: 26px 20px;
  background:
    radial-gradient(circle at top left, rgba(15,128,111,.23), transparent 20rem),
    var(--navy);
  color: #fff;
}

.sidebar-nav {
  display: grid;
  gap: 7px;
  margin-top: 44px;
}

.sidebar-nav a {
  padding: 12px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,.72);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.10);
  color: #fff;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
  color: rgba(255,255,255,.66);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.app-main {
  width: calc(100% - 260px);
  max-width: 1500px;
  margin-left: 260px;
  padding: 36px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-header h1 {
  margin: 7px 0 7px;
  font-size: clamp(34px, 5vw, 52px);
  letter-spacing: -.05em;
}

.page-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 17px;
  margin-bottom: 20px;
}

.stat-card,
.panel {
  border: 1px solid #e2e8ef;
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
}

.panel {
  margin-bottom: 20px;
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.panel-heading h2 {
  margin: 5px 0 0;
  font-size: 22px;
  letter-spacing: -.025em;
}

.search-input {
  width: min(100%, 280px);
}

.analysis-list {
  display: grid;
  gap: 10px;
}

.analysis-item {
  display: grid;
  grid-template-columns: minmax(0,1.6fr) .7fr .7fr .7fr auto;
  align-items: center;
  gap: 16px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}

.analysis-item:hover {
  border-color: #bac5d0;
  background: #fafcfd;
}

.analysis-item strong,
.analysis-item span {
  min-width: 0;
}

.analysis-item span {
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  width: max-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(15,128,111,.10);
  color: var(--teal) !important;
  font-size: 11px !important;
  font-weight: 800;
}

.status-badge.open {
  background: rgba(181,43,52,.08);
  color: var(--danger) !important;
}

.empty-state {
  margin: 0;
  padding: 24px;
  border: 1px dashed #cbd5df;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

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

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

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

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.help-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.deal-view {
  min-height: 170px;
}

.bridge-deal {
  display: grid;
  grid-template-areas:
    ". north ."
    "west center east"
    ". south .";
  grid-template-columns: repeat(3, minmax(160px,1fr));
  gap: 14px;
  align-items: start;
}

.hand-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafcfd;
}

.hand-card.north { grid-area: north; }
.hand-card.west { grid-area: west; }
.hand-card.east { grid-area: east; }
.hand-card.south { grid-area: south; }

.deal-center {
  grid-area: center;
  display: grid;
  min-height: 130px;
  place-items: center;
  border: 1px dashed #cbd5df;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.hand-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
}

.suit-line {
  display: flex;
  gap: 7px;
  line-height: 1.65;
}

.suit {
  width: 18px;
  font-weight: 800;
}

.suit.red {
  color: #c52232;
}

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

.auction-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

.auction-table th,
.auction-table td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.auction-table th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.auction-table input {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}

.auction-table input:focus {
  border-color: var(--teal);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
}

.category-fieldset {
  margin: 24px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.category-fieldset legend {
  padding: 0 7px;
  font-size: 12px;
  font-weight: 800;
}

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

.category-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #344156;
  font-size: 13px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-bottom: 36px;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: 100%;
    min-height: auto;
  }

  .sidebar-nav {
    grid-template-columns: repeat(2,1fr);
    margin: 24px 0;
  }

  .sidebar-footer {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .sidebar-footer .button {
    width: auto;
  }

  .app-main {
    width: 100%;
    margin-left: 0;
    padding: 24px;
  }

  .bridge-deal {
    grid-template-areas:
      "north north"
      "west east"
      "center center"
      "south south";
    grid-template-columns: repeat(2,minmax(0,1fr));
  }

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

@media (max-width: 700px) {
  .page-header,
  .panel-heading,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header .button,
  .header-actions .button,
  .search-input {
    width: 100%;
  }

  .stats-grid,
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .analysis-item {
    grid-template-columns: 1fr 1fr;
  }

  .analysis-item strong {
    grid-column: 1 / -1;
  }

  .bridge-deal {
    grid-template-areas:
      "north"
      "west"
      "east"
      "south"
      "center";
    grid-template-columns: 1fr;
  }

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

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .button {
    width: 100%;
  }
}
