:root {
  color-scheme: light;
  --bg: #eef5f7;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --text: #17212b;
  --muted: #637282;
  --line: rgba(116, 137, 158, 0.24);
  --focus: #0f8ea3;
  --button: #0d5665;
  --button-hover: #083d49;
  --disabled: #e8eef2;
  --danger: #b42318;
  --ready: #0c7a55;
  --shadow: 0 22px 60px rgba(20, 45, 57, 0.18);
  --gradient: linear-gradient(135deg, #0f8ea3 0%, #296fb0 48%, #13a36f 100%);
  --soft-gradient: linear-gradient(135deg, rgba(15, 142, 163, 0.12), rgba(19, 163, 111, 0.1));
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(145deg, rgba(15, 142, 163, 0.18) 0%, rgba(41, 111, 176, 0.12) 40%, rgba(19, 163, 111, 0.14) 100%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100%;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 24px;
  width: min(1360px, 100%);
  margin: 0 auto;
  align-items: start;
}

.exports-shell {
  width: min(980px, 100%);
  margin: 0 auto;
}

.control-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.control-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.control-panel::before {
  content: "";
  display: block;
  height: 5px;
  margin: -20px -20px 4px;
  background: var(--gradient);
}

.heading {
  display: grid;
  gap: 8px;
  margin-bottom: 4px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #0f8ea3;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: none;
}

.eyebrow svg {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  stroke: #0f8ea3;
  stroke-width: 2.3;
}

.brand-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 6px 14px rgba(15, 142, 163, 0.2);
}

.eyebrow span {
  background: linear-gradient(135deg, #0f8ea3 0%, #296fb0 58%, #123b67 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  color: #101922;
}

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

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

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input:focus {
  border-color: var(--focus);
  outline: 3px solid rgba(15, 142, 163, 0.18);
  background: #fff;
}

.field input:disabled {
  color: #55616e;
  background: linear-gradient(135deg, rgba(232, 238, 242, 0.94), rgba(246, 249, 250, 0.94));
  cursor: not-allowed;
}

.upload-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  padding: 11px 14px;
  color: #fff;
  background: linear-gradient(135deg, #12a87a 0%, #0f8ea3 54%, #296fb0 100%);
  box-shadow: 0 14px 28px rgba(15, 142, 163, 0.25);
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.upload-button.disabled {
  color: #89939e;
  background: linear-gradient(135deg, #e4eaee, #f2f5f7);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.upload-button:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(15, 142, 163, 0.3);
}

.upload-button.disabled:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.upload-button svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke-width: 2.2;
}

.upload-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-button:focus {
  outline: 3px solid rgba(15, 142, 163, 0.2);
  outline-offset: 3px;
}

.status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status.error {
  color: var(--danger);
}

.status.ready {
  color: var(--ready);
  font-weight: 700;
}

.download-actions {
  display: grid;
  gap: 10px;
}

.download-actions button,
.tab-button,
.primary-action {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.download-actions button,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 12px 24px rgba(13, 86, 101, 0.22);
}

.download-actions button svg,
.primary-action svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  stroke-width: 2.3;
}

.download-actions button:hover:not(:disabled),
.primary-action:hover:not(:disabled) {
  background: linear-gradient(135deg, #0c7788 0%, #225e9a 48%, #0f875c 100%);
  transform: translateY(-1px);
}

.download-actions button:disabled,
.primary-action:disabled {
  color: #89939e;
  background: linear-gradient(135deg, #e4eaee, #f2f5f7);
  box-shadow: none;
  cursor: not-allowed;
}

.primary-action {
  width: 100%;
}

.primary-action.loading svg {
  animation: spin 700ms linear infinite;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  color: #0d5665;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.secondary-link:hover {
  color: #083d49;
  text-decoration: none;
}

.inline-link {
  justify-content: flex-start;
  min-height: auto;
  gap: 7px;
}

.inline-link svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

.export-count {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.field-status,
.save-status {
  display: none;
  align-items: flex-start;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  border: 1px solid rgba(116, 137, 158, 0.2);
  border-radius: 10px;
  padding: 9px 10px;
  color: #36515d;
  background: rgba(240, 248, 250, 0.9);
  font-size: 13px;
  line-height: 1.35;
}

.save-status {
  display: flex;
  font-size: 14px;
}

.field-status.has-message {
  display: flex;
}

.field-status svg,
.save-status svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin-top: 1px;
  stroke: #0f8ea3;
  stroke-width: 2.3;
}

.field-status span,
.save-status span {
  min-width: 0;
}

.export-count.error,
.save-status.error {
  color: var(--danger);
}

.field-status.error,
.save-status.error {
  border-color: rgba(180, 35, 24, 0.18);
  color: #8f1f17;
  background: rgba(255, 241, 239, 0.94);
}

.field-status.error svg,
.save-status.error svg {
  stroke: var(--danger);
}

.export-count.ready,
.save-status.ready {
  color: var(--ready);
  font-weight: 700;
}

.records-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.74);
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.records-table th,
.records-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.records-table th {
  color: #36515d;
  background: rgba(240, 248, 250, 0.92);
  font-weight: 700;
}

.records-table td:first-child,
.records-table th:first-child {
  width: 1%;
  white-space: nowrap;
}

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

.field-status.ready,
.save-status.ready {
  border-color: rgba(12, 122, 85, 0.2);
  color: #0b6549;
  background: rgba(236, 252, 246, 0.94);
}

.field-status.ready svg,
.save-status.ready svg {
  stroke: var(--ready);
}

.save-status.loading {
  border-color: rgba(15, 142, 163, 0.2);
  background: rgba(238, 249, 252, 0.94);
}

.save-status.loading svg {
  animation: spin 700ms linear infinite;
}

.save-status.loading svg circle,
.save-status.loading svg line,
.save-status.loading svg path {
  stroke: #0f8ea3;
}

.status-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(15, 142, 163, 0.25);
  border-top-color: #0f8ea3;
  border-radius: 999px;
  vertical-align: -2px;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-panel {
  min-width: 0;
  padding: 16px;
}

.preview-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft-gradient);
}

.tab-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.66);
}

.tab-button.active {
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 10px 22px rgba(13, 86, 101, 0.18);
}

.preview-frame {
  display: grid;
  place-items: start center;
  width: 100%;
  padding: 10px 0 20px;
  overflow: hidden;
}

.preview-download-actions {
  width: min(100%, 520px);
  margin: 16px auto 0;
  justify-items: center;
}

.preview-download-actions button {
  width: auto;
  min-width: 210px;
}

.preview-download-actions button {
  display: none;
}

.preview-download-actions button.active {
  display: flex;
}

.records-card {
  width: min(1360px, 100%);
  margin: 24px auto 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.records-card .records-table {
  font-size: 14px;
}

.records-card .records-table th,
.records-card .records-table td {
  padding: 6px;
  vertical-align: middle;
}

.records-card .record-check {
  width: 24px;
  height: 24px;
}

.records-card .record-check svg {
  width: 16px;
  height: 16px;
  stroke-width: 3;
}

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

.records-card-header h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #0d5665;
  background: rgba(240, 248, 250, 0.92);
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(226, 244, 248, 0.96);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.3;
}

.records-table td:last-child,
.records-table th:last-child {
  width: 1%;
  text-align: left;
  white-space: nowrap;
}

.row-delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 8px;
  padding: 7px 10px;
  color: #8f1f17;
  background: rgba(255, 241, 239, 0.94);
  cursor: pointer;
  font-weight: 700;
}

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

.row-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(15, 142, 163, 0.2);
  border-radius: 8px;
  color: #0d5665;
  background: rgba(240, 248, 250, 0.94);
  cursor: pointer;
}

.row-icon-button:hover {
  background: rgba(226, 244, 248, 0.98);
}

.row-icon-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}

.row-delete-button:hover:not(:disabled) {
  background: rgba(255, 228, 224, 0.98);
}

.row-delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.row-delete-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}

.row-delete-button.loading svg {
  animation: spin 700ms linear infinite;
}

.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.56);
}

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

.modal-dialog {
  width: min(680px, 100%);
  max-height: min(92vh, 980px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.modal-body {
  max-height: calc(92vh - 68px);
  overflow: auto;
  padding: 14px;
  background: #f6f9fb;
}

.modal-body img {
  display: block;
  width: min(100%, 520px);
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.saving-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(31, 41, 55, 0.62);
}

.saving-overlay[hidden] {
  display: none;
}

.saving-overlay img {
  width: 82px;
  height: 82px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.26);
  animation: saving-rotate 1s linear infinite;
}

@keyframes saving-rotate {
  to {
    transform: rotate(360deg);
  }
}

.record-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: #fff;
  background: var(--ready);
}

.record-check svg {
  width: 16px;
  height: 16px;
  stroke-width: 3;
}

.preview-canvas {
  display: none;
  width: min(100%, 520px);
  height: auto;
  border: 1px solid rgba(116, 137, 158, 0.32);
  border-radius: 10px;
  background: var(--panel-solid);
  box-shadow: 0 8px 18px rgba(20, 45, 57, 0.1);
  image-rendering: auto;
}

.preview-canvas.active {
  display: block;
}

@media (max-width: 840px) {
  .app-shell {
    padding: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .control-panel,
  .preview-panel {
    border-radius: 8px;
  }

  .control-panel {
    padding: 16px;
  }

  h1,
  .eyebrow {
    font-size: 20px;
  }

  .eyebrow svg {
    width: 24px;
    height: 24px;
  }

  .brand-icon {
    width: 26px;
    height: 26px;
  }

  .download-actions {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    padding: 12px;
  }

  .preview-canvas {
    width: 100%;
  }

  .records-card .records-table {
    font-size: 8.4px;
  }

  .records-card .records-table th,
  .records-card .records-table td {
    padding: 6px;
  }

  .records-card .record-check {
    width: 17px;
    height: 17px;
  }

  .records-card .record-check svg {
    width: 11px;
    height: 11px;
  }
}
