:root {
  --sidebar: #172033;
  --sidebar-deep: #101827;
  --surface: #f5f7fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #6d7688;
  --accent: #1f7a68;
  --accent-soft: rgba(31, 122, 104, 0.14);
  --border: #dfe5ef;
  --shadow: 0 18px 40px rgba(16, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--surface);
  font-family: Arial, Helvetica, sans-serif;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 260px;
  padding: 22px 16px;
  color: #ffffff;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-deep));
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 8px 20px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-size: 18px;
}

.menu {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.74);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.menu-link:hover,
.menu-link:focus-visible,
.menu-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.menu-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 16px;
  line-height: 1;
}

.active .menu-icon {
  background: var(--accent-soft);
  color: #8ef0d7;
}

.page {
  min-height: 100vh;
  margin-left: 260px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar > :last-child {
  margin-left: auto;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.blank-state {
  min-height: calc(100vh - 72px);
  padding: 28px;
}

.workspace {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.is-hidden {
  display: none !important;
}

.pi-list-panel {
  margin: 24px 24px 0;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(16, 24, 39, 0.05);
}

.pi-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.pi-list-head h2 {
  margin: 0;
  font-size: 18px;
}

.pi-list-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pi-list-scroll {
  overflow: auto;
}

.pi-list-table {
  width: 100%;
  border-collapse: collapse;
}

.pi-list-table th,
.pi-list-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.pi-list-table th {
  color: #394456;
  font-size: 12px;
}

.pi-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pi-empty {
  padding: 26px;
  border: 1px dashed #9aa8bc;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.pi-workspace {
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  grid-template-areas:
    "upload form"
    "preview preview";
  align-items: start;
}

.pi-workspace .upload-panel {
  grid-area: upload;
}

.pi-workspace .entry-grid {
  grid-area: form;
}

.pi-workspace .po-preview-shell {
  grid-area: preview;
  display: flex;
  flex-direction: column;
}

.upload-panel,
.form-panel,
.po-preview-shell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(16, 24, 39, 0.05);
}

.upload-panel {
  display: grid;
  gap: 20px;
  padding: 20px;
}

.upload-panel h2,
.form-panel h2,
.po-preview-shell h2 {
  margin: 0;
  font-size: 17px;
}

.upload-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.upload-box {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 16px;
  border: 1px dashed #9aa8bc;
  border-radius: 8px;
  background: #f9fbfe;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-title {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

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

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

.form-panel {
  padding: 20px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.field-grid label {
  display: grid;
  gap: 6px;
  color: #394456;
  font-size: 12px;
  font-weight: 700;
}

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

.item-editor-scroll {
  overflow: auto;
  margin-top: 16px;
}

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

.item-editor-table th,
.item-editor-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.item-editor-table th {
  color: #394456;
  font-size: 12px;
}

.item-editor-table input {
  min-width: 78px;
}

.item-editor-table .description-input {
  min-width: 220px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  font: 14px Arial, Helvetica, sans-serif;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 104, 0.12);
  outline: none;
}

textarea {
  resize: vertical;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.actions button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.actions button:hover,
.actions button:focus-visible {
  border-color: #9aa8bc;
  background: #f8fafc;
  outline: none;
}

.actions .primary-button:hover,
.actions .primary-button:focus-visible {
  border-color: #176554;
  background: #176554;
}

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

.logout-button,
.login-button,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.logout-button:hover,
.logout-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible,
.danger-button:hover,
.danger-button:focus-visible {
  border-color: #9aa8bc;
  background: #f8fafc;
  outline: none;
}

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

.primary-button:hover,
.primary-button:focus-visible {
  border-color: #176554;
  background: #176554;
  outline: none;
}

.danger-button {
  color: #b42318;
}

.icon-button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: #b42318;
  font-weight: 700;
  cursor: pointer;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 122, 104, 0.14), transparent 36%),
    var(--surface);
}

.login-shell {
  width: min(100%, 420px);
}

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

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #394456;
  font-size: 13px;
  font-weight: 700;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
}

.login-button {
  width: 100%;
  min-height: 44px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.login-button:hover,
.login-button:focus-visible {
  border-color: #176554;
  background: #176554;
  outline: none;
}

.po-preview-shell {
  min-width: 0;
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.po-preview-stage {
  overflow: auto;
  padding: 18px;
  background: #eef2f7;
}

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

.po-document {
  width: 100%;
  min-width: 860px;
  min-height: 640px;
  margin: 0 auto;
  padding: 22px;
  background: #ffffff;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  box-shadow: 0 18px 36px rgba(16, 24, 39, 0.14);
}

.po-document h3 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 15px;
}

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

.po-table th,
.po-table td {
  border: 1px solid #000000;
  padding: 4px;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.po-table th {
  font-weight: 700;
  text-align: left;
}

.po-table .center,
.po-table th.center {
  text-align: center;
}

.po-table .right {
  text-align: right;
}

.po-table .bold {
  font-weight: 700;
}

.po-notes {
  margin: 14px 0 0;
  padding-left: 18px;
  font-weight: 700;
  line-height: 1.55;
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  place-items: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
}

@media (max-width: 760px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .page {
    margin-left: 0;
  }

  .topbar {
    padding: 0 18px;
  }

  .menu-toggle {
    display: grid;
  }

  .blank-state {
    padding: 18px;
  }

  .workspace {
    padding: 16px;
  }

  .pi-list-panel {
    margin: 16px 16px 0;
  }

  .pi-list-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .pi-list-table {
    min-width: 760px;
  }

  .upload-panel,
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .pi-workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "upload"
      "form"
      "preview";
  }

  .pi-workspace .po-preview-shell {
    position: static;
    max-height: none;
  }

  .upload-panel {
    display: grid;
  }

  .upload-box {
    min-width: 0;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .po-document {
    min-width: 820px;
    margin: 12px;
  }
}
