:root {
  color-scheme: light;
  --ink: #13201b;
  --muted: #64736c;
  --line: #d8e3dc;
  --panel: #ffffff;
  --panel-2: #f7faf8;
  --background: #edf3ef;
  --primary: #2f8f55;
  --primary-dark: #21673d;
  --primary-soft: #e4f4ea;
  --blue: #1e6bd6;
  --amber: #b7791f;
  --danger: #be3b3b;
  --shadow: 0 18px 45px rgba(23, 38, 30, 0.12);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body.theme-dark {
  color-scheme: dark;
  --ink: #eef7f1;
  --muted: #aebbb4;
  --line: #2e4337;
  --panel: #121c18;
  --panel-2: #172620;
  --background: #0b1210;
  --primary: #55ba78;
  --primary-dark: #3c955c;
  --primary-soft: #163522;
  --blue: #6ea8ff;
  --amber: #e9b65e;
  --danger: #f07a7a;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: var(--background);
  color: var(--ink);
}

body.app-locked {
  height: 100vh;
  overflow: hidden;
  background: #102019;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

img {
  max-width: 100%;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  isolation: isolate;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: #102019;
}

.login-screen::before,
.login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
}

.login-screen::before {
  z-index: -2;
  background-image: url("assets/tnwind-watermark-tile.png");
  background-repeat: repeat;
  background-size: 420px 250px;
  background-position: 24px 30px;
  opacity: 0.46;
}

.login-screen::after {
  z-index: -1;
  background: linear-gradient(135deg, rgba(16, 32, 25, 0.78), rgba(23, 71, 45, 0.84));
}

.billing-lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(38, 24, 10, 0.9), rgba(89, 50, 11, 0.84)),
    #1f160c;
}

.login-card {
  width: min(100%, 430px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 26px;
  color: #f8fafc;
  background: rgba(15, 24, 20, 0.88);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.billing-card {
  width: min(100%, 520px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 26px;
  color: #fff7ed;
  background: rgba(28, 20, 12, 0.9);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.billing-card .login-brand img {
  background: #ffffff;
}

.billing-message {
  margin: 0 0 18px;
  color: #fed7aa;
  line-height: 1.5;
}

.billing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.login-brand img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
}

.login-brand .treilo-brand-logo {
  width: 116px;
  height: 74px;
  background: #ffffff;
}

.login-brand p,
.login-brand h1,
.login-brand span {
  margin: 0;
}

.login-brand p {
  color: #b7d8c3;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.login-brand h1 {
  font-size: 38px;
  line-height: 1;
}

.login-brand span {
  display: block;
  margin-top: 6px;
  color: #d9e8de;
}

.login-form,
.data-form {
  display: grid;
  gap: 14px;
}

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

.login-form label {
  color: #e5f2e9;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--panel);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 143, 85, 0.15);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 74px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 5px 9px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 900;
  transform: translateY(-50%);
}

.primary-button,
.secondary-button,
.icon-text-button,
.quick-logins button,
.tabs-row button,
.side-nav button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 800;
}

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

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

.secondary-button,
.icon-text-button,
.quick-logins button,
.tabs-row button {
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel);
}

.secondary-button:hover,
.icon-text-button:hover,
.tabs-row button:hover {
  border-color: var(--primary);
}

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

.form-error,
.form-message {
  min-height: 20px;
  margin: 0;
  color: #ffb4b4;
  font-size: 13px;
  font-weight: 700;
}

.form-message {
  color: var(--primary-dark);
}

.demo-panel {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.demo-panel p,
.demo-panel small {
  margin: 0;
}

.demo-panel p {
  margin-bottom: 10px;
  color: #dcefe3;
  font-weight: 800;
}

.demo-panel small {
  display: block;
  margin-top: 10px;
  color: #bdd5c7;
}

.quick-logins {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-logins button {
  color: #eef7f1;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.version-panel {
  text-align: center;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(12px);
}

.hamburger-button,
.close-menu-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.hamburger-button {
  display: none;
  place-items: center;
  gap: 4px;
  padding: 10px;
}

.hamburger-button span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
}

.topbar-title {
  min-width: 0;
}

.topbar-title p,
.topbar-title h1 {
  margin: 0;
}

.topbar-title p,
.eyebrow {
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

body.theme-dark .topbar-title p,
body.theme-dark .eyebrow {
  color: #95e5ad;
}

.topbar-title h1 {
  font-size: 21px;
}

.app-body {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  gap: 18px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.side-menu {
  position: sticky;
  top: 84px;
  height: calc(100vh - 102px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-head,
.side-brand,
.user-badge,
.section-title,
.daily-note {
  display: flex;
  align-items: center;
}

.side-head,
.section-title,
.daily-note {
  justify-content: space-between;
  gap: 14px;
}

.side-brand,
.user-badge {
  min-width: 0;
  gap: 12px;
}

.side-brand img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.side-brand strong,
.side-brand span,
.user-badge b,
.user-badge small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-brand span,
.user-badge small,
.side-footer p,
.metric-card small,
.notice-box,
td small {
  color: var(--muted);
}

.close-menu-button {
  display: none;
  color: var(--ink);
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav button {
  width: 100%;
  color: var(--ink);
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.side-nav button.active,
.side-nav button:hover {
  color: var(--primary-dark);
  border-color: var(--line);
  background: var(--primary-soft);
}

body.theme-dark .side-nav button.active,
body.theme-dark .side-nav button:hover {
  color: #dffbe6;
}

.side-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.side-footer p {
  margin: 0;
  font-size: 12px;
}

.user-badge {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.user-badge span {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--primary-dark);
  font-weight: 900;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.daily-note {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--panel);
}

.lock-banner {
  border: 1px solid #f1b45b;
  border-radius: 8px;
  padding: 12px 14px;
  color: #653b00;
  background: #fff3d8;
}

body.theme-dark .lock-banner {
  color: #ffedd5;
  background: #59360d;
}

.daily-note p,
.daily-note strong {
  margin: 0;
}

.view {
  display: none;
  gap: 18px;
}

.view.active {
  display: grid;
}

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

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

.metric-card {
  display: grid;
  gap: 7px;
  min-height: 128px;
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  font-size: clamp(25px, 4vw, 36px);
  line-height: 1;
}

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

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.section-title {
  margin-bottom: 14px;
}

.section-title p,
.section-title h2 {
  margin: 0;
}

.section-title h2 {
  font-size: 20px;
}

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

.report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
}

.report-row strong,
.report-row span {
  display: block;
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--ink);
  background: #e9eef8;
  font-size: 12px;
  font-weight: 900;
}

.status-open {
  color: #6c3d00;
  background: #fff0cc;
}

.status-invoice {
  color: #0a4a2c;
  background: #dff5e7;
}

.status-done {
  color: #17406f;
  background: #dbeafe;
}

body.theme-dark .status-badge {
  color: #f8fafc;
  background: #233247;
}

body.theme-dark .status-open {
  background: #5a380e;
}

body.theme-dark .status-invoice {
  background: #123d27;
}

body.theme-dark .status-done {
  background: #173a60;
}

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

.scope-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.scope-list span {
  color: var(--muted);
}

.notice-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
  font-size: 13px;
  line-height: 1.45;
}

.filters-row,
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr {
  background: var(--panel);
}

tbody tr:hover {
  background: var(--primary-soft);
}

td {
  font-size: 14px;
}

.row-action {
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
  font-weight: 900;
}

.report-detail {
  min-height: 220px;
}

.empty-state {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px;
  color: var(--muted);
  background: var(--panel-2);
  text-align: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
}

.detail-item span,
.detail-item strong {
  display: block;
}

.detail-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-item strong {
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs-row button.active {
  color: #ffffff;
  border-color: var(--primary);
  background: var(--primary);
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 14px;
}

.document-card {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-2);
}

.document-card strong,
.document-card span {
  display: block;
}

.document-card span {
  color: var(--muted);
  line-height: 1.4;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.super-admin-panel {
  border-color: #f1b45b;
  background: color-mix(in srgb, var(--panel) 86%, #fff4db);
}

body.theme-dark .super-admin-panel {
  background: color-mix(in srgb, var(--panel) 82%, #5c370b);
}

.super-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.role-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
}

body.theme-dark .role-pill {
  color: #dffbe6;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  color: var(--ink);
  background: var(--panel);
  font-weight: 800;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.password-dialog {
  width: min(100% - 32px, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
}

.password-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.password-dialog h3,
.password-dialog p {
  margin: 0;
}

.password-dialog h3 {
  font-size: 22px;
}

.password-dialog > p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.print-sheet {
  display: none;
}

@media (max-width: 980px) {
  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .app-body {
    grid-template-columns: 1fr;
  }

  .hamburger-button,
  .close-menu-button {
    display: grid;
  }

  .side-menu {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    width: min(86vw, 320px);
    height: 100vh;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .side-menu.open {
    transform: translateX(0);
  }

  .app-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.36);
  }
}

@media (max-width: 700px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 9px 12px;
  }

  #themeToggle {
    display: none;
  }

  .app-body {
    padding: 12px;
  }

  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .login-card,
  .panel,
  .metric-card {
    padding: 14px;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .section-title > button {
    width: 100%;
  }

  table {
    min-width: 680px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .login-screen,
  .app-shell {
    display: none !important;
  }

  .print-sheet {
    display: block;
    color: #111827;
    padding: 24px;
    font-family: Arial, sans-serif;
  }

  .print-sheet h1 {
    margin: 0 0 18px;
    font-size: 24px;
  }

  .print-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .print-cell {
    border: 1px solid #cbd5e1;
    padding: 10px;
  }

  .print-cell span {
    display: block;
    color: #475569;
    font-size: 11px;
    text-transform: uppercase;
  }

  .print-cell strong {
    display: block;
    margin-top: 4px;
  }
}
