:root {
  color-scheme: light;
  --bg: #e5e5e5;
  --surface: #ffffff;
  --surface-strong: #f7f7f7;
  --ink: #202020;
  --muted: #757575;
  --line: #c9c9c9;
  --line-strong: #bdbdbd;
  --dark: #3c3c3c;
  --dark-2: #555555;
  --nav: #000000;
  --accent: #ff3b2e;
  --accent-strong: #e52f24;
  --danger: #7a241f;
  --pending: #fff4de;
  --approved: #e8f6ee;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

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

button {
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
}

.auth-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  border-top: 3px solid var(--accent);
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

.auth-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 400;
}

.app-shell {
  height: 100vh;
  min-height: 720px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  background: var(--nav);
  color: #ffffff;
}

.brand {
  flex: 0 0 auto;
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 22px 12px;
}

.brand-mark {
  display: block;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #e85a43;
  font-size: 42px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -2px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  color: #e85a43;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand p {
  margin-top: 4px;
  color: #d0d0d0;
  font-size: 12px;
  line-height: 1.1;
}

.nav {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  overflow-y: auto;
  padding: 10px 8px 12px 0;
  scrollbar-gutter: stable;
}

.nav-item {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #8f1712;
  border-radius: 0;
  padding: 0 16px;
  color: #ffffff;
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.nav-item::after {
  content: "›";
  color: #a5a5a5;
  font-size: 18px;
  line-height: 1;
}

.nav-item:hover,
.nav-item.is-active {
  background: #232323;
}

.nav-item.is-active {
  box-shadow: inset 4px 0 0 var(--accent);
}

.side-note {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px 18px;
  padding: 12px;
  border-top: 1px solid #8f1712;
  border-radius: 0;
  background: #1e1e1e;
  color: #d0d0d0;
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  padding: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 0 10px 0 18px;
  background: var(--dark);
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h2 {
  margin: 0;
  color: #ffffff;
  font-size: 22px;
  font-weight: 400;
}

.top-actions,
.toolbar,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-form input {
  min-width: 180px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.file-picker {
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  padding: 0 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

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

.secondary-button,
.ghost-button,
.file-picker {
  border: 0;
  background: #555555;
  color: #ffffff;
}

.secondary-button:hover,
.ghost-button:hover,
.file-picker:hover {
  background: var(--accent);
}

.danger-button {
  background: var(--danger);
  color: #ffffff;
}

.danger-button:hover {
  background: #5f1916;
}

.dialog-danger-button {
  margin-top: 8px;
}

.small-button {
  border: 0;
  border-radius: 3px;
  min-height: 30px;
  padding: 0 8px;
  background: #555555;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

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

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

.danger-small-button:hover {
  background: #5f1916;
}

.view {
  min-height: 0;
  display: none;
  overflow: auto;
  padding: 24px;
}

.view.is-visible {
  display: block;
}

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

.metric,
.panel,
.table-wrap {
  border: 1px solid #d8d8d8;
  border-radius: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 96px;
  padding: 16px 18px;
  border-top: 3px solid var(--accent);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: #444444;
  font-size: 30px;
  font-weight: 400;
}

.content-grid,
.data-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

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

.panel {
  padding: 0 18px 18px;
}

.panel-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #d0d0d0;
  margin-bottom: 12px;
}

.panel h3 {
  color: #555555;
  font-size: 18px;
  font-weight: 400;
}

.toolbar {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding: 16px 28px;
  border: 1px solid #d8d8d8;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar input,
.toolbar select {
  width: min(420px, 42vw);
  min-width: 220px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--ink);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  accent-color: var(--accent);
}

.dialog-form .checkbox-label {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 8px;
}

.dialog-form .checkbox-label input {
  width: 16px;
}

.user-form {
  display: grid;
  gap: 8px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(255, 59, 46, 0.18);
  border-color: #8f1712;
}

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

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #ffffff;
}

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

.select-column {
  width: 42px;
  text-align: center;
}

.action-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eeeeee;
  color: #555555;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f1f1f1;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 3px;
  padding: 0 7px;
  background: #eeeeee;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 3px;
  padding: 0 8px;
  background: #eeeeee;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.is-done {
  background: #dce8dc;
  color: #245126;
}

.status-pill.is-problem {
  background: #f3dedd;
  color: var(--danger);
}

.status-pill.is-canceled {
  color: var(--muted);
}

.is-overdue {
  color: var(--danger);
  font-weight: 700;
}

.branch-detail {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.item-thumb {
  display: block;
  width: 76px;
  height: 58px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  object-fit: cover;
  background: #f4f4f4;
}

.type-list,
.timeline,
.dictionary-list {
  display: grid;
  gap: 7px;
}

.type-row,
.movement-row,
.dictionary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #d2d2d2;
  border-radius: 0;
  padding: 11px 0;
  background: transparent;
}

.movement-row {
  display: grid;
}

.type-row:last-child,
.movement-row:last-child,
.dictionary-row:last-child {
  border-bottom: 0;
}

.dictionary-row {
  align-items: center;
}

.dictionary-row .muted {
  display: block;
  margin-top: 3px;
}

.muted,
.movement-row small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.48);
}

.dialog-form {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-top: 3px solid var(--accent);
  background: var(--surface);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #d2d2d2;
  padding-bottom: 10px;
}

.dialog-head h3 {
  margin: 0;
  color: #444444;
  font-size: 22px;
  font-weight: 400;
}

.dialog-form label {
  display: grid;
  gap: 0;
  color: #8a8a8a;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.dialog-form label input,
.dialog-form label select,
.dialog-form label textarea {
  margin-top: 6px;
  color: var(--ink);
  text-transform: none;
}

.icon-button {
  width: 28px;
  min-height: 28px;
  border-radius: 50%;
  padding: 0;
  background: #5d5d5d;
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
  text-transform: none;
}

.icon-button:hover {
  background: #464646;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
}

.file-picker input {
  display: none;
}

.danger-zone {
  border-top: 3px solid var(--danger);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 3px;
  background: #202020;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar {
    height: auto;
    overflow: visible;
  }

  .brand {
    min-height: 78px;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 0;
    overflow: visible;
  }

  .nav-item {
    justify-content: center;
    padding: 0 8px;
    text-align: center;
  }

  .nav-item::after {
    content: none;
  }

  .side-note {
    margin-top: 12px;
  }

  .workspace {
    height: auto;
    min-height: 0;
    display: block;
    overflow: visible;
  }

  .view {
    overflow: visible;
  }

  .metric-grid,
  .content-grid,
  .data-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 112px;
    align-items: stretch;
    flex-direction: column;
    justify-content: center;
    padding: 14px 16px;
  }

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

  .view {
    padding: 16px;
  }

  .toolbar {
    padding: 14px;
  }

  .toolbar input,
  .toolbar select {
    width: 100%;
    min-width: 0;
  }

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

  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button,
  .file-picker {
    width: 100%;
  }
}
