:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --text: #172026;
  --muted: #65727d;
  --line: #d8e0e6;
  --brand: #176b5d;
  --accent: #b85c38;
  --danger: #b42318;
  --focus: #2f80ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

body:not(.is-admin) .admin-only {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  border-color: var(--brand);
}

button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

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

input:focus,
select:focus,
button:focus,
.button-link:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto auto;
  gap: 8px;
}

.user-label {
  font-size: 13px;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  display: grid;
  width: min(100%, 420px);
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgb(23 32 38 / 10%);
}

.login-panel h1 {
  margin: 2px 0 8px;
  font-size: 26px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.login-api {
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.sidebar {
  padding: 16px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.object-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.object-button {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
}

.object-button.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: transparent;
}

.tab.is-active {
  background: var(--surface);
  border-color: var(--line);
  border-bottom-color: var(--surface);
  color: var(--brand);
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  padding: 14px;
}

.panel.is-active {
  display: block;
}

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

.toolbar input,
.toolbar select {
  max-width: 260px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.grid-form button {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.finance-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mini-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f7faf9);
}

.mini-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mini-card strong {
  font-size: 22px;
  line-height: 1.15;
}

.finance-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.finance-card {
  display: grid;
  gap: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.admin-section {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-form {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  margin-bottom: 0;
}

.admin-form button {
  grid-column: 1 / -1;
}

.card-head h3 {
  margin: 0;
  font-size: 16px;
}

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

.finance-form button {
  grid-column: span 2;
}

.journal-form textarea {
  grid-column: 1 / -1;
  min-height: 96px;
  resize: vertical;
}

.journal-form button {
  grid-column: 1 / -1;
}

.table-scroll {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f5f3;
  color: #34444e;
  font-size: 13px;
  font-weight: 700;
}

td.number,
th.number {
  text-align: right;
}

.timesheet-input {
  width: 64px;
  min-width: 64px;
  text-align: right;
}

.status-good {
  color: var(--brand);
}

.status-warn {
  color: var(--accent);
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  min-height: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #172026;
  color: white;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

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

@media (max-width: 900px) {
  .topbar,
  .layout {
    display: block;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
    margin-top: 12px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

  .finance-form button,
  .admin-form button {
    grid-column: auto;
  }
}
