:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #65717b;
  --line: #dbe1e6;
  --surface: #ffffff;
  --canvas: #f5f6f2;
  --quiet: #eef1f3;
  --green: #176b5b;
  --green-soft: #dcebe5;
  --blue: #315f9d;
  --gold: #a66f19;
  --coral: #b5523d;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.manager-open .app-shell {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #ffffff;
  font-weight: 850;
}

.brand strong {
  display: block;
}

.all-files-button {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.all-files-button b {
  color: var(--muted);
  font-size: 0.78rem;
}

.all-files-button + .all-files-button {
  margin-top: 8px;
}

.all-files-button.active,
.all-files-button:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--green);
  font-weight: 760;
}

.directory-panel {
  margin-top: 30px;
}

.section-title,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title p,
.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.section-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.panel-head span {
  display: none;
}

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

.directory-row {
  display: grid;
  min-height: 42px;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  padding-left: calc(var(--directory-depth, 0) * 18px);
  border: 1px solid transparent;
  border-radius: 8px;
}

.directory-toggle,
.directory-toggle-placeholder {
  display: grid;
  width: 30px;
  min-height: 38px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
}

.directory-toggle:hover {
  background: var(--quiet);
  color: var(--green);
}

.directory-toggle-placeholder {
  pointer-events: none;
}

.directory-button {
  display: flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.directory-button b {
  color: var(--muted);
  font-size: 0.78rem;
}

.directory-row.active,
.directory-row:hover {
  border-color: var(--line);
  background: var(--surface);
}

.directory-row.active .directory-button,
.directory-row:hover .directory-button {
  color: var(--green);
  font-weight: 760;
}

.delete-directory-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.delete-directory-button:hover {
  background: #f4e6e2;
  color: var(--coral);
}

.delete-directory-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  margin-top: 16px;
}

.add-form input,
.add-form select,
.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.add-form input,
.add-form select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.manager-directory-form {
  grid-template-columns: minmax(140px, 0.75fr) minmax(0, 1fr) 42px;
}

.subdirectory-row .directory-button span {
  color: var(--muted);
}

.subdirectory-row.active .directory-button span,
.subdirectory-row:hover .directory-button span {
  color: var(--green);
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.search-wrap {
  display: grid;
  min-height: 48px;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-wrap svg,
.icon-button svg,
.text-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.search-wrap svg {
  justify-self: center;
  color: var(--muted);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.icon-button:hover {
  color: var(--coral);
}

.text-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  place-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 760;
  text-decoration: none;
}

.text-button:hover {
  border-color: var(--green);
  color: var(--green);
}

.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.text-button:disabled:hover {
  border-color: var(--line);
  color: var(--ink);
}

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

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

.text-button.danger:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.icon-button.danger:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.hero-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 28px 0 18px;
}

.hero-strip[hidden],
#resourcePanel[hidden],
#contactPanel[hidden] {
  display: none;
}

.image-tile {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.image-tile img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
}

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

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.45fr);
  gap: 16px;
  align-items: start;
}

.content-grid.single-view {
  grid-template-columns: 1fr;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel-head {
  min-height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.contact-filter-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.contact-filter-bar[hidden] {
  display: none;
}

.contact-filter-bar select {
  width: min(100%, 280px);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

.resource-list,
.contact-list {
  display: grid;
  max-height: min(72vh, 760px);
  overflow: auto;
  gap: 1px;
  background: var(--line);
}

.resource-card,
.contact-card {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
}

.resource-card {
  display: grid;
  gap: 8px;
}

.latest-file-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.file-meta {
  min-width: 0;
}

.file-meta h3 {
  overflow-wrap: anywhere;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.resource-card span {
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 780;
}

.resource-card h3,
.contact-card h3 {
  margin-bottom: 0;
  font-size: 1.04rem;
}

.resource-card p,
.contact-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.resource-card small {
  color: var(--muted);
}

.contact-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
}

.manager-contact-list {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.manager-contact-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.manager-contact-card h4,
.manager-contact-card p {
  margin: 0;
}

.manager-contact-card h4 {
  font-size: 0.92rem;
}

.manager-contact-card p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.manager-empty {
  min-height: 34px;
}

.avatar {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: #edf2f8;
  color: var(--blue);
  font-weight: 850;
}

.contact-card a {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--green);
  text-decoration: none;
}

.contact-card a:hover {
  text-decoration: underline;
}

.contact-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.delete-contact-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.delete-contact-button:hover {
  background: #f4e6e2;
  color: var(--coral);
}

.delete-contact-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  gap: 6px;
  padding: 24px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.manager-panel {
  min-height: 100vh;
  overflow: auto;
  padding: 24px;
  background: var(--canvas);
}

.manager-panel[hidden] {
  display: none;
}

.manager-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--surface);
}

.manager-module,
.manager-grid {
  max-width: 1240px;
  width: 100%;
  margin-right: auto;
  margin-left: auto;
}

.manager-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.manager-head h2,
.manager-module h3 {
  margin: 0;
  font-size: 1rem;
}

.manager-module {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.manager-head + .manager-module {
  margin-top: 16px;
}

.manager-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.manager-section + .manager-section,
.manager-module + .manager-module {
  margin-top: 16px;
}

.manager-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 780;
  cursor: pointer;
  list-style: none;
}

.manager-section summary::-webkit-details-marker {
  display: none;
}

.manager-section summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.manager-section[open] summary::after {
  transform: translateY(3px) rotate(225deg);
}

.manager-section summary b {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.92rem;
}

.manager-section input {
  width: 100%;
}

.manager-search-wrap {
  padding: 12px 16px 0;
}

.manager-search-wrap input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

.manager-directory-form {
  min-width: min(100%, 320px);
}

.manager-directory-list {
  display: grid;
  width: 100%;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 16px;
}

.manager-directory-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 36px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.manager-edit-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.manager-directory-fields {
  display: grid;
  gap: 4px;
}

.manager-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.manager-directory-card p,
.manager-edit-card p {
  margin: 0;
}

.manager-directory-card input,
.manager-edit-card input,
.manager-edit-card select,
.manager-edit-card textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.manager-directory-card input,
.manager-edit-card input,
.manager-edit-card select {
  min-height: 38px;
  padding: 0 10px;
}

.manager-edit-card textarea {
  resize: vertical;
  padding: 9px 10px;
}

.manager-directory-card p,
.manager-edit-card p {
  color: var(--muted);
  font-size: 0.82rem;
}

.manager-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  justify-items: stretch;
  gap: 16px;
  padding-top: 16px;
  background: transparent;
}

.manager-form {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 10px;
}

.manager-form input,
.manager-form select,
.manager-form textarea,
.file-upload-control {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.manager-form input,
.manager-form select,
.file-upload-control {
  min-height: 42px;
  padding: 0 12px;
}

.manager-form textarea {
  resize: vertical;
  padding: 10px 12px;
}

.file-upload-control {
  display: flex;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
}

.file-upload-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-name {
  min-height: 20px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.84rem;
}

.manager-note {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.manager-list,
.manager-contact-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 0 16px 16px;
}

.file-link {
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--green);
  font-weight: 760;
  text-decoration: none;
}

.file-link:hover {
  text-decoration: underline;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(23, 32, 38, 0.42);
}

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

.password-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(23, 32, 38, 0.42);
}

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

.password-dialog {
  display: grid;
  width: min(100%, 380px);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 70px rgba(23, 32, 38, 0.22);
}

.password-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.password-head h2 {
  margin: 0;
  font-size: 1rem;
}

.password-error {
  margin: -4px 0 0;
  color: var(--coral);
  font-size: 0.84rem;
}

.preview-dialog {
  display: grid;
  width: min(1120px, 100%);
  height: calc(100vh - 44px);
  max-height: 920px;
  grid-template-rows: 58px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.preview-head h2 {
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-body {
  min-height: 0;
  overflow: auto;
  background: #f3f5f7;
}

.preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.preview-fallback {
  display: grid;
  min-height: 100%;
  place-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.preview-fallback strong {
  color: var(--ink);
}

.document-preview {
  width: min(840px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 42px 52px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.85;
}

.document-preview p {
  margin: 0 0 1.1em;
  white-space: pre-wrap;
}

.preview-download-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
}

.preview-download-bar span {
  min-width: 0;
}

.preview-download-bar .text-button {
  flex: none;
}

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

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

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

  .hero-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .directory-list,
  .manager-grid,
  .manager-directory-form {
    grid-template-columns: 1fr;
  }

  .latest-file-card {
    grid-template-columns: 1fr;
  }

  .file-actions {
    justify-content: flex-start;
  }

  h1 {
    font-size: 2rem;
  }

  .image-tile,
  .image-tile img {
    min-height: 190px;
  }
}

/* Simple directory manager: add child / edit / delete beside each directory */
.manager-directory-card.simple-directory-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding-left: calc(10px + var(--directory-depth, 0) * 22px);
}

.manager-directory-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.manager-directory-name {
  min-width: 0;
}

.manager-directory-name strong {
  display: block;
  overflow-wrap: anywhere;
}

.manager-directory-name p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.manager-directory-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.manager-directory-edit-form,
.manager-child-directory-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.manager-directory-edit-form input,
.manager-child-directory-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

@media (max-width: 720px) {
  .manager-directory-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .manager-directory-actions {
    justify-content: flex-start;
  }

  .manager-directory-edit-form,
  .manager-child-directory-form {
    grid-template-columns: 1fr;
  }
}


.preview-inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
