:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #1d2830;
  --muted: #62727d;
  --line: #d7e0e4;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --ok: #16703a;
  --bad: #b42318;
  --warn: #8a5a00;
  --shadow: 0 12px 28px rgba(29, 40, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 44%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary,
button.tab {
  background: #e6ecef;
  color: var(--ink);
}

button.secondary:hover,
button.tab:hover {
  background: #d6e0e4;
}

button.danger {
  background: var(--bad);
}

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

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

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

.shell {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.toolbar,
.section-title,
.actions,
.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.toolbar,
.section-title {
  justify-content: space-between;
}

.toolbar {
  margin: 8px 0 14px;
}

.control-row {
  flex-wrap: wrap;
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.login {
  display: grid;
  gap: 18px;
  width: min(430px, calc(100vw - 28px));
  margin: 12vh auto;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

button.tab.active,
.segmented button.active {
  background: var(--accent);
  color: white;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
}

.form-grid {
  display: grid;
  gap: 13px;
}

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

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

.check {
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: start;
}

.check input {
  width: 18px;
  min-height: 18px;
}

.error {
  color: var(--bad);
  font-weight: 700;
}

.success {
  color: var(--ok);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: rgba(22, 112, 58, 0.12);
  color: var(--ok);
}

.badge.bad {
  background: rgba(180, 35, 24, 0.12);
  color: var(--bad);
}

.calendar-board {
  display: grid;
  gap: 10px;
}

.calendar-board.month {
  grid-template-columns: repeat(7, minmax(130px, 1fr));
}

.calendar-board.week {
  grid-template-columns: repeat(7, minmax(150px, 1fr));
}

.calendar-board.day {
  grid-template-columns: minmax(240px, 1fr);
}

.day-cell {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.day-cell header {
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 10px;
}

.day-events {
  display: grid;
  gap: 7px;
  padding: 8px;
}

.booking-pill {
  display: grid;
  gap: 2px;
  min-height: 0;
  border-left: 5px solid var(--booking-color);
  background: color-mix(in srgb, var(--booking-color) 12%, white);
  color: var(--ink);
  padding: 8px;
  text-align: left;
}

.booking-pill:hover {
  background: color-mix(in srgb, var(--booking-color) 20%, white);
}

.booking-pill span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.dialog {
  margin-top: 14px;
}

.flight-layout,
.aircraft-layout,
.fuel-layout,
.users-layout,
.config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 14px;
  align-items: start;
}

.flight-layout .panel:nth-child(4) {
  grid-column: 1;
}

.cost-box {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
}

.cost-box dl {
  display: grid;
  gap: 10px;
}

.cost-box dl div,
.metric-grid div {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.cost-box dt,
.metric-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.cost-box dd,
.metric-grid strong {
  font-size: 22px;
  font-weight: 850;
}

.cost-box .total {
  border-bottom: 0;
  padding: 12px;
  border-radius: 8px;
  background: #e9f4f2;
}

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

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

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

.color-chip {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chip);
}

@media (max-width: 980px) {
  .calendar-board.month,
  .calendar-board.week {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flight-layout,
  .aircraft-layout,
  .fuel-layout,
  .users-layout,
  .config-layout {
    grid-template-columns: 1fr;
  }

  .cost-box {
    position: static;
  }

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

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 18px, 1500px);
    padding-top: 12px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-board.month,
  .calendar-board.week,
  .grid.two,
  .metric-grid {
    grid-template-columns: 1fr;
  }

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