:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --text: #17202a;
  --muted: #64748b;
  --line: #dbe3ee;
  --line-strong: #cbd5e1;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --done: #0f8a5f;
  --due: #c48a08;
  --bad: #c24135;
  --muted-state: #8b95a1;
  --focus: #2563eb;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

.hidden {
  display: none !important;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #eef3f7;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-brand {
  color: var(--text);
  border-bottom-color: var(--line);
  margin-bottom: 16px;
}

.auth-brand span {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-message {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.auth-message.error {
  color: var(--bad);
}

.user-badge {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

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

.sidebar {
  background: #10202b;
  color: #edf6f5;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 4px;
  color: #a8bbc5;
  font-size: 13px;
}

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

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  color: #d9e7e8;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.sidebar-panel {
  display: grid;
  gap: 8px;
  color: #c8d6dc;
}

.sidebar-panel select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px;
  color: #fff;
  background: #162f3c;
}

.legend {
  margin-top: auto;
  display: grid;
  gap: 9px;
  color: #c8d6dc;
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: -1px;
  background: var(--muted-state);
}

.dot.done {
  background: var(--done);
}

.dot.due {
  background: var(--due);
}

.dot.bad {
  background: var(--bad);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 840px;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

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

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.top-actions select,
.control,
.field input,
.field select,
.field textarea {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}

.primary,
.secondary,
.danger {
  border: 0;
  border-radius: 8px;
  padding: 10px 13px;
  font-weight: 700;
}

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

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

.secondary {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.danger {
  color: #fff;
  background: var(--bad);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

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

.start-guide {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.start-guide-inner {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.4fr);
  gap: 16px;
  padding: 16px;
}

.start-guide p {
  margin: 8px 0 0;
  color: var(--muted);
}

.step-list {
  display: grid;
  gap: 9px;
}

.step-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

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

.step-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.metric {
  min-height: 102px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

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

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 16px;
}

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

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

.panel-body {
  padding: 15px;
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.period-card {
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.period-card button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  text-align: left;
  font-weight: 800;
}

.period-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  white-space: normal;
  text-align: center;
}

.status-done {
  background: var(--done);
}

.status-due {
  background: var(--due);
}

.status-missing,
.status-overdue {
  background: var(--bad);
}

.status-na {
  background: var(--muted-state);
}

.small {
  color: var(--muted);
  font-size: 13px;
}

.todo-list,
.alert-list {
  display: grid;
  gap: 10px;
}

.todo-item,
.alert-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--panel-soft);
}

.alert-item strong,
.todo-item strong {
  display: block;
  margin-bottom: 4px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: #3b4a5a;
  background: #f8fafc;
  font-size: 13px;
}

tbody tr:hover {
  background: #fbfdff;
}

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

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.icon-button {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

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

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

.upload-area {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  background: #f8fafc;
}

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

.deadline-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 0.5fr) minmax(120px, 0.45fr) minmax(160px, 0.7fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.folder-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.25fr);
  gap: 16px;
  align-items: start;
}

.folder-tree {
  overflow: auto;
  max-height: 68vh;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  line-height: 1.65;
}

.folder-tree ul {
  margin: 0;
  padding-left: 20px;
}

.folder-tree li {
  list-style: none;
}

.folder-tree li::before {
  content: "□";
  margin-right: 8px;
  color: var(--primary);
}

.folder-root {
  color: var(--text);
  font-weight: 800;
}

.folder-help,
.folder-current-note {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.folder-help span,
.folder-current-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.folder-branch {
  display: grid;
  gap: 5px;
  margin-top: 6px;
  padding-left: 16px;
}

.folder-tree details {
  border-left: 1px solid var(--line);
  padding-left: 11px;
}

.folder-tree summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.folder-tree summary span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.folder-node {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 4px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.folder-node:hover,
.folder-node.selected {
  border-color: var(--line-strong);
  background: #fff;
}

.folder-node small {
  white-space: nowrap;
  color: var(--muted);
}

.folder-node small.done {
  color: var(--done);
}

.folder-node small.bad {
  color: var(--bad);
}

.folder-detail-panel {
  position: sticky;
  top: 16px;
}

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

.month-file-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.month-file-cell {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  display: grid;
  place-items: center;
  gap: 2px;
}

.month-file-cell:hover {
  border-color: var(--primary);
}

.month-file-cell span {
  color: var(--muted);
  font-size: 12px;
}

.month-file-cell strong {
  font-size: 20px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #10202b;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    position: static;
  }

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

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

  .summary-grid,
  .grid-two,
  .start-guide-inner,
  .folder-layout {
    grid-template-columns: 1fr;
  }

  .folder-detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .panel-header {
    display: grid;
  }

  .top-actions,
  .filters,
  .inline-actions {
    width: 100%;
  }

  .top-actions select,
  .top-actions button,
  .filters .field,
  .filters button {
    width: 100%;
  }

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

  .deadline-row {
    grid-template-columns: 1fr;
  }

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

  .step-item {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .step-item button {
    grid-column: 1 / -1;
    width: 100%;
  }
}
