:root {
  --ink: #1d2a38;
  --muted: #607284;
  --line: #d8e1eb;
  --paper: #ffffff;
  --surface: #edf3f8;
  --blue: #1657b8;
  --blue-dark: #103d7f;
  --green: #0f8b68;
  --amber: #b7791f;
  --shadow: 0 24px 60px rgba(24, 37, 52, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(22, 87, 184, 0.14), transparent 24%),
    linear-gradient(180deg, #f7fafd 0%, var(--surface) 100%);
}

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

.login-shell,
.project-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.login-shell {
  background:
    radial-gradient(circle at top left, rgba(20, 71, 138, 0.26), transparent 34%),
    linear-gradient(135deg, #0d2342 0%, #133a6d 48%, #edf4fb 48%, #f7fafc 100%);
}

.login-card {
  width: min(980px, 100%);
  min-height: min(640px, calc(100vh - 48px));
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(11, 24, 42, 0.22);
  backdrop-filter: blur(12px);
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 420px);
  gap: 26px;
}

.brand-panel {
  background: linear-gradient(160deg, rgba(10, 43, 89, 0.98), rgba(17, 74, 145, 0.96));
  color: white;
  border-radius: 16px;
  padding: 30px;
  display: grid;
  align-content: space-between;
  gap: 24px;
}

.brand-mark {
  width: 124px;
  height: 124px;
  border: 15px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  position: relative;
}

.brand-mark::before {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  width: 58px;
  height: 38px;
  background: #fff;
  transform: translateY(-50%);
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 26px;
  top: 24px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    linear-gradient(45deg, transparent 47%, #fff 48%, #fff 56%, transparent 57%),
    linear-gradient(90deg, transparent 42%, #fff 43%, #fff 58%, transparent 59%),
    linear-gradient(135deg, transparent 44%, #fff 45%, #fff 53%, transparent 54%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.brand-panel .eyebrow {
  color: rgba(255,255,255,0.78);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 42px; line-height: .98; }
h2 { font-size: 24px; }
h3 { font-size: 16px; }

.copy,
.subcopy {
  color: var(--muted);
  line-height: 1.5;
}

.brand-panel .copy {
  color: rgba(255,255,255,0.82);
  max-width: 420px;
}

.login-panel {
  display: grid;
  align-content: center;
  gap: 14px;
}

.demo-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

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

.field span,
.detail-grid dt {
  font-size: 12px;
  font-weight: 800;
  color: #425466;
}

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #ccd7e4;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

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

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22, 87, 184, 0.12);
}

.error {
  min-height: 18px;
  color: #c24141;
  font-size: 12px;
}

.actions,
.detail-actions,
.modal-head,
.detail-head,
.filters,
.metric-row,
.tabs,
.doc-toolbar,
.toolbar,
.sidebar-head,
.user-box {
  display: flex;
  gap: 10px;
}

.button,
.icon-button,
.tab {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  min-height: 40px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

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

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.button.full { width: 100%; }

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 20px;
}

.project-modal {
  background: rgba(15, 23, 42, 0.42);
}

.project-modal[hidden] { display: none; }

.modal-card {
  width: min(860px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.modal-head { align-items: center; justify-content: space-between; }
.modal-form { display: grid; gap: 14px; }

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

.field.full { grid-column: 1 / -1; }

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

.sidebar {
  background: #e8eef5;
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
}

.section-head { margin-bottom: 10px; }

.tree-list {
  overflow: auto;
  padding-right: 4px;
  display: grid;
  gap: 4px;
}

.tree-row {
  border: 0;
  background: transparent;
  color: #334155;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.tree-row:hover,
.tree-row.active { background: #dbe7f3; }

.tree-main {
  font-weight: 700;
  color: #1f2933;
}

.tree-sub {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 10px;
}

.user-box {
  flex-direction: column;
  align-items: flex-start;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-height: 24px;
  padding: 2px 10px;
  background: #e8f1ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.content,
.detail {
  padding: 20px;
  overflow: auto;
  max-height: 100vh;
}

.content-head {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.metric-row {
  flex-wrap: wrap;
}

.metric {
  flex: 1 1 160px;
  min-height: 96px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 32px;
}

.filters {
  flex-wrap: wrap;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.filters .field { flex: 0 0 180px; }
.filters .field.grow { flex: 1 1 260px; }

.table-panel,
.detail-summary,
.detail-workspace {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}

.table-panel { overflow: auto; }

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

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

th {
  background: #edf2f7;
  color: #425466;
  font-size: 12px;
}

tbody tr { cursor: pointer; }
tbody tr:hover,
tbody tr.selected { background: #f0f6ff; }

.detail-summary {
  padding: 16px;
}

.detail-head {
  align-items: start;
  justify-content: space-between;
  border-bottom: 3px solid #223044;
  padding-bottom: 14px;
}

.detail-grid {
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fafbfd;
}

.detail-grid dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.path-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f1f5f9;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.detail-workspace {
  margin-top: 14px;
  padding: 14px;
}

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

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  padding: 10px 12px;
  min-height: auto;
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

#detailPanel {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.summary-box,
.document-row,
.log-row,
.empty-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

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

.summary-box strong { display: block; margin-top: 4px; }

.upload-form,
.doc-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

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

.doc-group {
  display: grid;
  gap: 10px;
}

.doc-group-head,
.version-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.document-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.document-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.done { background: #e6f6ef; color: var(--green); }
.status.review { background: #fff7df; color: var(--amber); }
.status.draft { background: #e9f1ff; color: var(--blue); }

.version-list {
  display: grid;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.version-row {
  border: 1px solid #e7edf4;
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.empty-box {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .detail {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .login-card,
  .app,
  .grid,
  .detail-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .content, .detail, .sidebar {
    max-height: none;
  }

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

  .doc-group-head,
  .version-row {
    flex-direction: column;
  }

  .filters .field,
  .filters .field.grow {
    flex: 1 1 100%;
  }
}
