:root {
      --bg-1: #07111f;
      --bg-2: #0b1728;
      --panel: rgba(14, 24, 40, 0.82);
      --panel-strong: rgba(10, 18, 31, 0.95);
      --panel-soft: rgba(255, 255, 255, 0.04);
      --border: rgba(120, 180, 255, 0.18);
      --border-strong: rgba(120, 180, 255, 0.28);
      --text: #ebf3ff;
      --text-soft: #9eb2ce;
      --text-muted: #6f84a2;
      --primary: #2f8cff;
      --primary-hover: #1f79eb;
      --secondary: #18273c;
      --secondary-hover: #22344d;
      --success: #18b26b;
      --danger: #ef5350;
      --warning: #ffb020;
      --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
      --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.22);
      --radius-xl: 24px;
      --radius-lg: 18px;
      --radius-md: 14px;
      --radius-sm: 10px;
      --glow: 0 0 0 1px rgba(47, 140, 255, 0.15), 0 0 24px rgba(47, 140, 255, 0.08);
    }

    * {
      box-sizing: border-box;
    }

    html, body {
      margin: 0;
      padding: 0;
      min-height: 100%;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--text);
      background:
        radial-gradient(circle at top left, rgba(47, 140, 255, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(0, 234, 255, 0.08), transparent 24%),
        linear-gradient(145deg, var(--bg-1) 0%, var(--bg-2) 100%);
    }

    body {
      padding: 22px;
    }

    a {
      color: var(--text-soft);
      text-decoration: none;
      transition: 0.2s ease;
    }

    a:hover {
      color: #ffffff;
    }

    #mainApp {
      max-width: 1560px;
      margin: 0 auto;
    }

    nav {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      padding: 16px 18px;
      margin-bottom: 22px;
      background: rgba(8, 16, 28, 0.78);
      border: 1px solid var(--border);
      border-radius: 20px;
      box-shadow: var(--shadow-soft);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      position: sticky;
      top: 14px;
      z-index: 50;
    }

    nav ul {
      list-style: none;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin: 0;
      padding: 0;
    }

    nav li {
      margin: 0;
      padding: 0;
    }

    nav a {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 40px;
      padding: 0 14px;
      border-radius: 12px;
      background: rgba(255,255,255,0.03);
      border: 1px solid transparent;
      font-size: 13px;
      font-weight: 600;
      letter-spacing: 0.2px;
    }

    nav a:hover {
      background: rgba(255,255,255,0.06);
      border-color: var(--border);
    }

    .app-shell {
      display: flex;
      gap: 22px;
      align-items: flex-start;
    }

    .main-panel {
      flex: 1;
      min-width: 0;
    }

    .container,
    .history-panel {
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: var(--radius-xl);
      box-shadow: var(--shadow);
      overflow: hidden;
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }

    .history-panel {
      width: 460px;
      min-width: 360px;
    }

    .title-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 18px 22px;
      border-bottom: 1px solid var(--border);
      background:
        linear-gradient(90deg, rgba(47, 140, 255, 0.12), rgba(0, 234, 255, 0.03)),
        rgba(255,255,255,0.02);
    }

    .title-bar span {
      font-size: 15px;
      font-weight: 700;
      color: #f4f8ff;
      letter-spacing: 0.35px;
    }

    .title-bar::after {
      content: "";
      width: 10px;
      height: 10px;
      border-radius: 999px;
      background: #00d4ff;
      box-shadow: 0 0 16px rgba(0, 212, 255, 0.8);
      flex-shrink: 0;
    }

    .window-content {
      padding: 24px;
    }

    h1 {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    label {
      display: block;
      margin-bottom: 8px;
      font-size: 13px;
      font-weight: 700;
      color: #dbe8fb;
      letter-spacing: 0.2px;
    }

    textarea,
    input[type="text"],
    input[type="date"],
    input[type="time"],
    select {
      width: 100%;
      margin-bottom: 16px;
      padding: 13px 14px;
      border-radius: 14px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      color: var(--text);
      font-size: 14px;
      outline: none;
      transition: 0.2s ease;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    }

    textarea::placeholder,
    input::placeholder {
      color: #7e92af;
    }

    textarea:focus,
    input[type="text"]:focus,
    input[type="date"]:focus,
    input[type="time"]:focus,
    select:focus {
      border-color: var(--border-strong);
      box-shadow: var(--glow);
      background: rgba(255,255,255,0.06);
    }

    textarea {
      min-height: 130px;
      resize: vertical;
    }

    .control-row {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      margin-bottom: 10px;
    }

    .control-row select {
      width: auto;
      min-width: 185px;
      margin-bottom: 0;
    }

    button {
      appearance: none;
      border: 1px solid transparent;
      border-radius: 12px;
      padding: 11px 16px;
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 0.2px;
      cursor: pointer;
      transition: 0.2s ease;
      color: #ffffff;
      background: var(--primary);
      box-shadow: 0 8px 20px rgba(47, 140, 255, 0.26);
    }

    button:hover {
      transform: translateY(-1px);
      background: var(--primary-hover);
    }

    button.secondary {
      background: var(--secondary);
      color: var(--text);
      border-color: var(--border);
      box-shadow: none;
    }

    button.secondary:hover {
      background: var(--secondary-hover);
    }

    #aircraftSelection {
      display: none;
      margin-bottom: 18px;
      padding: 16px;
      border-radius: 16px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
    }

    #aircraftSelection span {
      display: inline-block;
      margin-bottom: 10px;
      font-size: 13px;
      color: var(--text-soft);
      font-weight: 700;
    }

    #aircraftSelection label {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      margin-right: 18px;
      margin-bottom: 8px;
      font-weight: 600;
      color: #d6e3f8;
    }

    #aircraftSelection input[type="checkbox"] {
      width: auto;
      margin: 0;
      accent-color: var(--primary);
    }

    .error,
    .success {
      display: none;
      margin-bottom: 16px;
      padding: 13px 14px;
      border-radius: 14px;
      font-size: 13px;
      font-weight: 700;
      border: 1px solid transparent;
    }

    .error {
      background: rgba(239, 83, 80, 0.12);
      border-color: rgba(239, 83, 80, 0.24);
      color: #ffb7b5;
    }

    .success {
      background: rgba(24, 178, 107, 0.14);
      border-color: rgba(24, 178, 107, 0.24);
      color: #a9f0cb;
    }

    #outputList {
      margin-top: 18px;
    }

    .scr-group {
      margin-bottom: 16px;
      padding: 16px;
      border-radius: 18px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.03);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
    }

    .heading {
      margin-bottom: 10px;
      font-size: 13px;
      font-weight: 800;
      color: #8fd0ff;
      letter-spacing: 0.4px;
      text-transform: uppercase;
    }

    .output-container {
      margin-top: 8px;
      padding: 14px;
      border-radius: 14px;
      border: 1px solid rgba(143, 208, 255, 0.16);
      background: rgba(3, 9, 18, 0.78);
      color: #cfe6ff;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      font-size: 12.5px;
      white-space: pre-wrap;
      word-wrap: break-word;
      max-height: 400px;
      overflow-y: auto;
    }

    .output-container pre {
      margin: 0;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .send-button-container {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 12px;
    }

    .send-button-container button,
    .history-actions button,
    .history-toolbar button,
    .history-editor-actions button {
      padding: 9px 12px;
      font-size: 12px;
    }

    .history-toolbar {
      padding: 18px;
      border-bottom: 1px solid var(--border);
      background: rgba(255,255,255,0.02);
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .history-toolbar input[type="text"] {
      width: 100%;
      margin-bottom: 0;
    }

    .history-note {
      width: 100%;
      font-size: 12px;
      color: var(--text-muted);
      margin-bottom: 2px;
    }

    .history-list {
      padding: 18px;
      max-height: 780px;
      overflow-y: auto;
    }

    .history-empty {
      padding: 16px;
      border-radius: 14px;
      border: 1px dashed var(--border);
      background: rgba(255,255,255,0.025);
      color: var(--text-soft);
      font-size: 13px;
    }

    .history-item {
      margin-bottom: 12px;
      padding: 14px;
      border-radius: 16px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
    }

    .history-item-title {
      font-size: 13px;
      font-weight: 800;
      color: #eef6ff;
      margin-bottom: 7px;
    }

    .history-item-meta {
      font-size: 12px;
      color: var(--text-soft);
      line-height: 1.55;
      margin-bottom: 8px;
    }

    .history-item-preview,
    .history-editor-header,
    .history-editor-si,
    .scr-preview-box {
      padding: 12px;
      border-radius: 12px;
      border: 1px solid rgba(143, 208, 255, 0.14);
      background: rgba(4, 10, 18, 0.75);
      color: #c8e0ff;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      font-size: 12px;
      white-space: pre-wrap;
      margin-bottom: 8px;
    }

    .history-item-preview {
      max-height: 90px;
      overflow: hidden;
    }

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

    .history-editor {
      margin-top: 12px;
      padding: 12px;
      border-radius: 16px;
      border: 1px solid var(--border);
      background: rgba(0,0,0,0.18);
    }

    .history-editor-actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 10px;
    }

    .modified-scr-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
      margin-bottom: 8px;
      padding: 10px;
      border-radius: 14px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.03);
    }

    .modified-scr-row label {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 0;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-soft);
      white-space: nowrap;
    }

    .modified-scr-row input[type="text"],
    .modified-scr-row input[type="date"],
    .modified-scr-row input[type="time"],
    .modified-scr-row select {
      width: auto;
      min-width: 60px;
      margin-bottom: 0;
      padding: 8px 10px;
      font-size: 12px;
      flex-grow: 1;
    }

    .modified-scr-row input.r-flight { flex-grow: 0; width: 90px; }
    .modified-scr-row input.r-date { flex-grow: 0; width: 132px; }
    .modified-scr-row input.r-day { flex-grow: 0; width: 85px; background-color: rgba(255,255,255,0.08); }
    .modified-scr-row input.r-combined-code { flex-grow: 0; width: 110px; text-transform: uppercase; }
    .modified-scr-row input.r-time { flex-grow: 0; width: 82px; }
    .modified-scr-row input.r-airport { flex-grow: 0; width: 70px; text-transform: uppercase; }
    .modified-scr-row select.r-service { flex-grow: 0; width: 65px; }

    .changed-field {
      border-color: rgba(255, 176, 32, 0.7) !important;
      background: rgba(255, 176, 32, 0.1) !important;
      box-shadow: 0 0 0 1px rgba(255,176,32,0.2) !important;
    }

    .changed-row {
      background: rgba(255, 176, 32, 0.05) !important;
    }

    .change-indicator {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 4px 8px;
      border-radius: 999px;
      background: rgba(255,176,32,0.12);
      border: 1px solid rgba(255,176,32,0.3);
      color: #ffd37f;
      font-size: 10px;
      font-weight: 800;
    }

    .scr-preview-highlight {
      background: rgba(255,176,32,0.16);
      color: #ffd37f;
      font-weight: 700;
      padding: 0 2px;
      border-radius: 4px;
    }

    .modal {
      display: none;
      position: fixed;
      z-index: 1000;
      inset: 0;
      width: 100%;
      height: 100%;
      padding: 24px;
      background: rgba(2, 7, 14, 0.7);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      overflow: auto;
    }

    .modal-content {
      width: min(900px, 94%);
      margin: 5% auto;
      padding: 22px;
      border-radius: 20px;
      background: var(--panel-strong);
      border: 1px solid var(--border-strong);
      box-shadow: var(--shadow);
      color: var(--text);
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      white-space: pre-wrap;
      max-height: 78vh;
      overflow-y: auto;
    }

    .modal-content pre {
      margin: 0;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .close-button {
      float: right;
      font-size: 28px;
      font-weight: 400;
      color: var(--text-soft);
      cursor: pointer;
      line-height: 1;
    }

    .close-button:hover {
      color: #ffffff;
    }

    footer {
      margin-top: 18px;
      text-align: center;
      font-size: 12px;
      color: var(--text-muted);
      line-height: 1.6;
    }

    @media (max-width: 1200px) {
      .app-shell {
        flex-direction: column;
      }

      .history-panel {
        width: 100%;
        min-width: unset;
      }

      .history-list {
        max-height: 420px;
      }
    }

    @media (max-width: 720px) {
      body {
        padding: 12px;
      }

      nav,
      .window-content,
      .history-toolbar,
      .history-list {
        padding-left: 14px;
        padding-right: 14px;
      }

      .modified-scr-row {
        flex-direction: column;
        align-items: stretch;
      }

      .modified-scr-row label {
        width: 100%;
        justify-content: space-between;
      }

      .modified-scr-row input,
      .modified-scr-row select {
        width: auto;
      }

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

      .control-row select,
      .control-row button {
        width: 100%;
      }
    }
