:root {
  color-scheme: light;
  --bg: #f5f6f1;
  --panel: #ffffff;
  --ink: #20252b;
  --muted: #69727d;
  --line: #d8ded8;
  --accent: #126a5f;
  --accent-dark: #0c5149;
  --focus: rgba(18, 106, 95, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(32, 37, 43, 0.08);
  padding: 24px;
}

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

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

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 74px;
  height: 52px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.status {
  min-width: 98px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-size: 13px;
  white-space: nowrap;
}

form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.pattern-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: 16px Arial, Helvetica, sans-serif;
  padding: 11px 12px;
  outline: none;
  background: #fff;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
}

.field-with-action.field-without-action {
  grid-template-columns: minmax(0, 1fr);
}

.field-icon-button {
  min-width: 48px;
  width: 48px;
  padding: 0;
  font-size: 22px;
}

.inline-notice {
  border: 1px solid rgba(18, 106, 95, 0.28);
  border-radius: 6px;
  background: #edf5f2;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  padding: 12px 14px;
}

.pending-active-notice {
  margin-bottom: 2px;
}

.quick-fill-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -8px;
}

.text-action {
  background: transparent;
  border: 0;
  color: var(--accent);
  font: 700 14px Arial, Helvetica, sans-serif;
  min-height: 28px;
  min-width: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-action:hover {
  background: transparent;
  color: var(--accent-dark);
}

.field-counter {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.field-counter.limit-reached {
  color: #9d3030;
  font-weight: 700;
}

.print-frame {
  border: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  width: 0;
}

.span-2 {
  grid-column: span 2;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 6px;
}

.app-credit {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  margin-top: 22px;
  padding-top: 14px;
  text-align: center;
}

.app-credit a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.app-credit a:hover {
  text-decoration: underline;
}

.action-group {
  display: flex;
  gap: 12px;
}

button {
  min-width: 128px;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: 700 15px Arial, Helvetica, sans-serif;
  padding: 0 18px;
}

.button-link {
  min-width: 128px;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 15px Arial, Helvetica, sans-serif;
  padding: 0 18px;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-dark);
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

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

button.secondary:hover,
.secondary-link:hover {
  background: #edf5f2;
}

.secondary-link {
  background: #fff;
  color: var(--accent);
}

.pending-top-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  font-size: 13px;
  min-height: 34px;
  min-width: 150px;
  padding: 0 12px;
  text-align: center;
  white-space: nowrap;
}

.header-actions .button-link {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  font-size: 13px;
  min-height: 34px;
  min-width: 150px;
  padding: 0 12px;
  text-align: center;
  white-space: nowrap;
}

.patterns-dialog {
  width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 18px 54px rgba(32, 37, 43, 0.18);
}

#quickFillDialog {
  width: min(680px, calc(100% - 32px));
}

.patterns-dialog::backdrop {
  background: rgba(32, 37, 43, 0.28);
}

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

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

.icon-button {
  min-width: 36px;
  min-height: 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.patterns-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.dialog-controls {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  padding: 16px 18px;
}

.marine-flow {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.dialog-footer {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  padding: 14px 18px;
}

.empty-patterns {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.pattern-option {
  width: 100%;
  min-height: 42px;
  text-align: left;
  justify-content: flex-start;
}

.pending-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
}

.pending-option {
  align-items: flex-start;
  background: #fff;
  color: var(--ink);
  display: grid;
  gap: 5px;
  padding: 12px 14px;
}

.pending-option:hover {
  background: #edf5f2;
}

.pending-option span,
.pending-option small {
  color: var(--muted);
  font-weight: 400;
}

.pending-delete-button {
  align-self: stretch;
  background: #fff;
  border-color: #b84a4a;
  color: #9d3030;
  font-size: 20px;
  min-height: 42px;
  min-width: 36px;
  padding: 0;
}

.pending-delete-button:hover {
  background: #fff0f0;
}

.patterns-admin {
  display: grid;
  gap: 18px;
  align-items: start;
  max-width: 100%;
}

.options-admin {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 18px;
  margin-top: 28px;
  padding-top: 24px;
}

.patterns-admin-left {
  display: grid;
  gap: 18px;
}

.patterns-admin-form {
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.patterns-admin-form textarea {
  min-height: 220px;
}

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

.list-header h2,
.patterns-admin-form h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.pattern-selector-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.pattern-select-field {
  flex: 1;
}

.selected-pattern-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 1px;
}

.small-button {
  min-width: 88px;
  min-height: 36px;
  font-size: 14px;
  padding: 0 14px;
}

.option-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.option-type-button.active {
  background: var(--accent);
  color: #fff;
}

button.danger {
  background: #fff;
  border-color: #b84a4a;
  color: #9d3030;
}

button.danger:hover {
  background: #fff0f0;
}

.pattern-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.pattern-form-actions button {
  min-width: 136px;
}

.selected-pattern-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  margin: 0;
  min-height: 110px;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 980px);
    padding: 16px 0;
  }

  .panel {
    padding: 18px;
  }

  .panel-header {
    flex-direction: column;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .brand-block {
    align-items: flex-start;
  }

  .brand-logo {
    width: 58px;
    height: 42px;
  }

  h1 {
    font-size: 24px;
  }

  form {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .action-group {
    flex-direction: column-reverse;
  }

  .date-pair {
    grid-template-columns: 1fr;
  }

  .patterns-admin-form {
    padding: 16px;
  }

  .pattern-selector-row {
    align-items: stretch;
    flex-direction: column;
  }

  .selected-pattern-actions {
    padding-bottom: 0;
  }

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

  .pattern-form-actions {
    flex-direction: column-reverse;
  }

  button,
  .button-link {
    width: 100%;
  }
}
