:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #687684;
  --line: #d9e0e7;
  --accent: #0c6b58;
  --accent-strong: #084d40;
  --danger: #b42318;
  --warning-bg: #fff7df;
  --disabled-bg: #eef1f4;
  --disabled-text: #8b97a3;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f5f7f9 0%, #e7eef2 100%);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(23, 32, 42, 0.12);
}

.login-brand {
  margin-bottom: 22px;
  color: var(--text);
}

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

.login-panel p {
  color: var(--muted);
}

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #f0b4ae;
  border-radius: 8px;
  color: var(--danger);
  background: #fff1ef;
}

.login-panel form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.login-panel label {
  font-weight: 700;
}

.login-panel input,
.login-panel select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100vh;
  padding: 84px 18px 24px;
  overflow-y: auto;
  background: #17202a;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: #18a086;
  font-weight: 700;
}

.brand span,
.user-box span {
  display: block;
  margin-top: 2px;
  color: #bcc7d1;
  font-size: 13px;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  color: #eff6f5;
  background: transparent;
  cursor: pointer;
}

.nav-button:hover,
.nav-button.active {
  background: #22303c;
  border-color: #344655;
}

.nav-button.disabled {
  color: #8794a0;
  background: #202932;
  cursor: not-allowed;
}

.user-box {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 232px;
  margin-top: 0;
  padding: 9px 10px;
  border: 1px solid #344655;
  border-radius: 8px;
  background: rgba(32, 41, 50, 0.96);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.user-box strong {
  display: block;
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.user-box button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 28px;
}

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

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

h1 {
  margin-bottom: 4px;
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.topbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.readiness,
.notice,
.panel,
.metric,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.readiness {
  min-width: 210px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice.error {
  border-color: #f0b4ae;
  color: var(--danger);
  background: #fff1ef;
}

.hidden {
  display: none;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
}

.metric {
  min-height: 96px;
  padding: 16px;
}

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

.metric small {
  display: block;
  margin-top: 8px;
  font-size: 12px;
}

.metric span,
.metric small,
.empty,
.disabled-panel,
.small-muted {
  color: var(--muted);
}

.metric.disabled-metric {
  color: var(--disabled-text);
  background: var(--disabled-bg);
}

.metric.disabled-metric strong,
.metric.disabled-metric span,
.metric.disabled-metric small {
  color: var(--disabled-text);
}

.panel {
  padding: 18px;
}

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

.notification-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid #cfe6df;
  border-radius: 8px;
  background: #f2fbf8;
}

.notification-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

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

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

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

th {
  color: #354554;
  background: #f8fafb;
  font-size: 13px;
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.just-uploaded-row td {
  background: #eef9f5;
}

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

button.primary,
button.secondary,
button.danger,
.link-button {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

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

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

button.secondary {
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

.link-button.secondary {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

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

button:disabled {
  color: var(--disabled-text);
  background: var(--disabled-bg);
  border-color: var(--line);
  cursor: not-allowed;
}

.disabled-panel {
  padding: 18px;
  border: 1px dashed #c5ccd3;
  border-radius: 8px;
  background: var(--disabled-bg);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #084d40;
  background: #e2f6f1;
  font-size: 12px;
}

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.file-icon {
  display: inline-grid;
  width: 38px;
  height: 30px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: #5b6875;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.file-icon-doc {
  background: #2368b8;
}

.file-icon-xls {
  background: #0c7a43;
}

.file-icon-ppt {
  background: #b7471d;
}

.file-icon-pdf {
  background: #b42318;
}

.file-icon-txt,
.file-icon-file {
  background: #5b6875;
}

.new-file-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #084d40;
  background: #dff6ed;
  font-size: 11px;
  font-weight: 700;
}

.upload-dropzone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 82px;
  margin-bottom: 14px;
  padding: 16px;
  border: 2px dashed #8aa0b4;
  border-radius: 8px;
  background: #f8fafb;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.upload-dropzone strong,
.upload-dropzone span {
  display: block;
}

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

.upload-dropzone.drag-ready {
  border-color: #2f8d78;
  background: #edf8f4;
}

.upload-dropzone.drag-over {
  border-color: var(--accent);
  background: #dff5ee;
  box-shadow: 0 0 0 4px rgba(12, 107, 88, 0.12);
}

.upload-dropzone.drag-over strong::after {
  content: " per caricare";
}

.upload-dropzone.disabled-upload {
  color: var(--disabled-text);
  background: var(--disabled-bg);
  border-color: var(--line);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 8px;
  color: #354554;
  background: #eef1f4;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.approved {
  color: #084d40;
  background: #dff6ed;
}

.status-badge.rejected {
  color: #8f130c;
  background: #ffe5e1;
}

.status-badge.pending {
  color: #60440b;
  background: #fff2c6;
}

.status-badge.closed {
  color: #354554;
  background: #e6ebef;
}

.flow-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.flow-filters button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.flow-filters .active-filter {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.flow-filters span {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  color: inherit;
  background: rgba(255, 255, 255, 0.18);
  text-align: center;
  font-size: 12px;
}

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

.editor-dialog {
  width: min(1680px, calc(100vw - 16px));
  height: min(980px, calc(100vh - 16px));
}

.editor-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.editor-header h2 {
  margin: 4px 0 5px;
  font-size: 26px;
  line-height: 1.15;
}

.editor-header p {
  margin: 0;
  color: var(--muted);
}

.editor-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.editor-document-title {
  max-width: min(920px, calc(100vw - 560px));
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.editor-body {
  min-height: 0;
  background: #eef1f4;
}

.editor-main {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 360px;
  min-height: 0;
}

.editor-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.editor-empty {
  display: grid;
  min-height: 280px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.editor-meta {
  display: grid;
  align-content: start;
  gap: 0;
  min-width: 0;
  padding: 18px;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #fff;
}

.editor-meta-section {
  display: grid;
  gap: 12px;
  padding: 0 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.editor-meta-section h3 {
  margin: 0;
  font-size: 16px;
}

.editor-meta-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.compact {
  padding: 7px 10px;
}

.editor-action-list {
  display: grid;
  gap: 8px;
}

.editor-action-list .link-button,
.editor-action-list button {
  justify-content: center;
  width: 100%;
}

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

.meta-grid div {
  display: grid;
  gap: 3px;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 13px;
}

.meta-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #243447;
  font-size: 12px;
  font-weight: 700;
}

.editor-workflow-state {
  display: grid;
  gap: 6px;
}

.editor-workflow-state > span,
.editor-workflow-state small {
  color: var(--muted);
}

.version-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.version-list li {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.version-list span,
.version-list small {
  color: var(--muted);
}

.upload-dialog {
  width: min(560px, calc(100vw - 32px));
}

.upload-progress-panel {
  padding: 20px;
}

.upload-progress-panel header p {
  margin-bottom: 0;
  color: var(--muted);
}

.upload-file-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  margin: 16px 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.upload-file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.upload-file-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.upload-file-list small {
  flex: 0 0 auto;
  color: var(--muted);
}

.upload-progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e0e7;
}

.upload-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 140ms ease;
}

.upload-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.upload-error .upload-progress-fill {
  background: var(--danger);
}

.upload-error #uploadProgressStatus {
  color: var(--danger);
}

.dialog-form {
  padding: 20px;
}

.dialog-form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.dialog-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.dialog-form input,
.dialog-form select {
  width: 100%;
  min-height: 40px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dialog-summary {
  margin-bottom: 16px;
  color: var(--muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text);
}

.checkbox-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding-top: 84px;
  }

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

  .topbar,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  .editor-dialog {
    height: min(920px, calc(100vh - 24px));
  }

  .editor-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 1fr) auto;
  }

  .editor-document-title {
    max-width: 100%;
  }

  .editor-meta {
    max-height: 260px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 18px;
  }

  .metrics,
  .main-nav {
    grid-template-columns: 1fr;
  }
}
