:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #121212;
  --surface-soft: #191919;
  --surface-strong: #202020;
  --ink: #f8f8f8;
  --muted: #b9c3cb;
  --line: #2e3438;
  --line-strong: #52616b;
  --accent: #ff5a00;
  --accent-dark: #d64400;
  --accent-soft: rgba(255, 90, 0, 0.16);
  --blue-line: rgba(146, 177, 205, 0.35);
  --danger: #ff4b4b;
  --danger-soft: rgba(255, 75, 75, 0.15);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(255, 90, 0, 0.09) 0 34px, transparent 34px 64px, rgba(146, 177, 205, 0.09) 64px 70px, transparent 70px),
    var(--bg);
  color: var(--ink);
  font-family:
    "Arial Narrow",
    "Roboto Condensed",
    "Segoe UI",
    system-ui,
    sans-serif;
  line-height: 1.4;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid #252525;
  border-radius: 8px;
  background: #050505;
  box-shadow: var(--shadow);
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("iomtt-lines.svg") right 22px center / 80px 84px no-repeat;
  opacity: 0.32;
  pointer-events: none;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: var(--accent);
}

.brand-lockup {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: clamp(126px, 16vw, 174px);
  height: auto;
  flex: 0 0 auto;
}

.brand-copy {
  min-width: 0;
  padding-left: 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  text-transform: uppercase;
}

h1 {
  color: #fff;
  font-size: clamp(1.6rem, 2.7vw, 2.45rem);
  font-weight: 900;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 1.05rem;
}

.topbar-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.filename-field {
  display: grid;
  gap: 4px;
  width: min(270px, 34vw);
}

.filename-field span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.filename-field input {
  height: 42px;
  min-height: 42px;
  font-size: 0.9rem;
}

.icon-button,
.ghost-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease,
    color 0.15s ease;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.icon-button.small {
  width: 32px;
  height: 32px;
}

.icon-button svg,
.primary-button svg,
.search-box svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button:hover,
.ghost-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.icon-button:active,
.primary-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

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

.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.metric-card {
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #151515, #0d0d0d);
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: #fff;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
  line-height: 1;
}

.work-area {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.entry-form,
.records-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  position: sticky;
  top: 16px;
}

.form-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  gap: 12px;
}

.entry-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.entry-form label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.wide {
  grid-column: 1 / -1;
}

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

textarea {
  resize: vertical;
  min-height: 82px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[readonly] {
  background: #1c1c1c;
  color: var(--muted);
  cursor: not-allowed;
}

.primary-button {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 900;
  text-transform: uppercase;
}

.primary-button:hover {
  background: #ff7a2d;
  border-color: #ff7a2d;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
  font-weight: 900;
  text-transform: uppercase;
}

.records-panel {
  min-width: 0;
  overflow: hidden;
}

.records-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr);
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #080808;
  color: var(--muted);
}

.search-box input {
  min-height: 0;
  height: 100%;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.table-wrap {
  position: relative;
  overflow: auto;
  min-height: 320px;
  max-height: calc(100vh - 256px);
}

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

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--accent);
  color: #101010;
  font-size: 0.82rem;
  white-space: nowrap;
}

thead th button {
  width: 100%;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 900;
  text-align: inherit;
  text-transform: uppercase;
}

thead th button::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 7px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  vertical-align: middle;
}

thead th button[aria-sort="ascending"]::after {
  border-bottom: 6px solid currentColor;
}

thead th button[aria-sort="descending"]::after {
  border-top: 6px solid currentColor;
}

tbody td {
  background: #101010;
  font-size: 0.9rem;
}

tbody tr:hover td {
  background: #171717;
}

.comments-cell {
  max-width: 320px;
  white-space: pre-wrap;
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  gap: 6px;
  min-width: 82px;
}

.actions-heading {
  width: 96px;
}

.empty-state {
  position: absolute;
  inset: 72px 0 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
  pointer-events: none;
  text-transform: uppercase;
}

.empty-state[hidden] {
  display: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #050505;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 900;
}

@media (max-width: 1100px) {
  .work-area {
    grid-template-columns: 1fr;
  }

  .entry-form {
    position: static;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1680px);
    padding-top: 14px;
  }

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

  .topbar-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .filename-field {
    width: min(100%, 320px);
  }

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

@media (max-width: 540px) {
  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .brand-copy {
    padding-left: 0;
    border-left: 0;
  }

  .entry-form {
    grid-template-columns: 1fr;
  }

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

  .metric-card {
    min-height: 78px;
  }
}
