:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --panel: #ffffff;
  --ink: #1d2520;
  --muted: #66736d;
  --line: #dce2db;
  --accent: #226f54;
  --accent-2: #c07b28;
  --danger: #ad3f35;
  --soft: #eaf3ee;
  --shadow: 0 12px 30px rgba(25, 36, 31, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #17241f;
  color: #f8fbf8;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #ffffff;
  text-transform: uppercase;
  font-weight: 800;
}

.brand small,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.sidebar .brand small {
  color: #b9c6bf;
}

.module-nav {
  display: grid;
  gap: 6px;
}

.module-nav button {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 11px 12px;
  color: #dce8e2;
  background: transparent;
  text-align: left;
}

.module-nav button.active,
.module-nav button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.11);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 246, 242, 0.94);
  backdrop-filter: blur(12px);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.65rem;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.25rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.topbar-actions,
.dialog-actions,
.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.session-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.88rem;
}

.primary-button,
.ghost-button,
.icon-button,
.chip-button {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
}

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

.ghost-button:hover,
.chip-button:hover,
.primary-button:hover {
  filter: brightness(0.96);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.view {
  padding: 26px 28px 40px;
}

.login-panel {
  max-width: 640px;
  margin: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

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

.metrics {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.two-col {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.84rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar input,
.toolbar select,
.form-grid input,
.form-grid select,
.form-grid textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.status.warn {
  background: #fff0dd;
  color: var(--accent-2);
}

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

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

.lane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.lane h3 {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.task {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 12px;
  margin-top: 10px;
}

.checklist {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.checklist-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--ink);
}

.checklist-item input {
  margin-top: 3px;
}

.task p,
.timeline p,
.document-preview p {
  color: var(--muted);
}

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

.timeline-item {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

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

dialog {
  width: min(900px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 23, 20, 0.45);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.document-preview {
  padding: 28px;
  background: #ffffff;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 18px;
  margin-bottom: 22px;
}

.doc-lines {
  margin: 22px 0;
}

.doc-total {
  display: flex;
  justify-content: flex-end;
  font-size: 1.2rem;
  font-weight: 800;
}

.dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 16px 18px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px;
  }

  .module-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

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

  .metrics,
  .two-col,
  .kanban,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  dialog,
  dialog * {
    visibility: visible;
  }

  dialog {
    position: static;
    width: 100%;
    border: 0;
    box-shadow: none;
  }

  .dialog-head,
  .dialog-actions {
    display: none;
  }
}
