/* ═══════════════════════════════════════
   EC2 Launcher — Clean Admin Theme
   Color: charcoal #333 + warm accents
   ═══════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 13px; line-height: 1.5;
  background: #eef0f4;
  color: #333;
}
.hidden { display: none !important; }
.error-text { color: #c0392b; font-size: 12px; margin-top: 4px; }
.muted { color: #999; }
.mono { font-family: "SF Mono", Consolas, "Courier New", monospace; font-size: 12px; }

/* ── Login ── */
.login-page {
  display: flex; align-items: center; justify-content: center; height: 100vh;
  background: #2c2c2c;
}
.login-box {
  width: 380px; background: #fff; padding: 36px 32px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.3);
  border-radius: 6px;
}
.login-box h1 {
  font-size: 22px; font-weight: 700; margin-bottom: 24px;
  color: #333; text-align: center; letter-spacing: 1px;
}
.login-box input {
  display: block; width: 100%; padding: 10px 14px; margin-bottom: 14px;
  background: #fafafa; border: 1px solid #ddd; border-radius: 4px;
  color: #333; font-size: 13px; outline: none; transition: all .2s;
}
.login-box input:focus { border-color: #666; background: #fff; box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.login-box button {
  width: 100%; padding: 11px; background: #333; color: #fff; border: none;
  border-radius: 4px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: background .2s; letter-spacing: .5px;
}
.login-box button:hover { background: #555; }

/* ── Top Nav Bar ── */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #333; padding: 0 16px; height: 44px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  position: sticky; top: 0; z-index: 100;
}
.top-bar-brand {
  font-size: 15px; font-weight: 700; color: #fff;
  letter-spacing: 1px; margin-right: 24px; white-space: nowrap;
}
.top-bar-nav { display: flex; gap: 0; height: 100%; }
.top-bar-nav a {
  display: flex; align-items: center; padding: 0 18px;
  color: rgba(255,255,255,.6); text-decoration: none;
  font-size: 13px; font-weight: 500; transition: all .15s;
  border-bottom: 2px solid transparent; height: 100%;
}
.top-bar-nav a:hover { color: rgba(255,255,255,.9); background: rgba(255,255,255,.06); }
.top-bar-nav a.active { color: #fff; border-bottom-color: #e67e22; background: rgba(255,255,255,.08); }
.top-bar-right { display: flex; align-items: center; gap: 10px; }
.top-bar-right .btn-logout {
  padding: 4px 12px; font-size: 11px; color: rgba(255,255,255,.6);
  border: 1px solid rgba(255,255,255,.2); background: transparent;
  border-radius: 3px; cursor: pointer; transition: all .15s;
}
.top-bar-right .btn-logout:hover { color: #fff; border-color: rgba(255,255,255,.5); }

/* ── Page Container ── */
.page-wrap { padding: 16px 20px; max-width: 1600px; margin: 0 auto; }

/* ── Page Header ── */
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-header h2 { font-size: 18px; font-weight: 700; color: #333; }

/* ── Toolbar / Filter Bar ── */
.toolbar {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center;
  padding: 10px 14px; background: #fff; border: 1px solid #e0e0e0;
  border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.toolbar .sep { width: 1px; height: 22px; background: #e0e0e0; margin: 0 4px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="text"], .toolbar input[type="date"], .toolbar select {
  padding: 6px 10px; border: 1px solid #d0d0d0; border-radius: 4px;
  font-size: 12px; outline: none; background: #fff; color: #333;
  transition: border-color .15s;
}
.toolbar input:focus, .toolbar select:focus { border-color: #888; box-shadow: 0 0 0 2px rgba(0,0,0,.05); }
.toolbar input[type="text"] { width: 180px; }
.toolbar select { min-width: 100px; }

/* ── Buttons ── */
button, .btn {
  padding: 6px 14px; background: #fff; color: #333; border: 1px solid #ccc;
  border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit;
  font-weight: 500; transition: all .15s; white-space: nowrap;
}
button:hover, .btn:hover { background: #f5f5f5; border-color: #aaa; }
.btn-primary { background: #333; color: #fff; border-color: #333; }
.btn-primary:hover { background: #555; border-color: #555; }
.btn-accent { background: #e67e22; color: #fff; border-color: #e67e22; }
.btn-accent:hover { background: #d35400; border-color: #d35400; }
.btn-danger { background: #fff; color: #c0392b; border-color: #c0392b; }
.btn-danger:hover { background: #fef5f5; }
.btn-danger-fill { background: #c0392b; color: #fff; border-color: #c0392b; }
.btn-danger-fill:hover { background: #a93226; }
.btn-warn { background: #f39c12; color: #fff; border-color: #f39c12; }
.btn-warn:hover { background: #e67e22; border-color: #e67e22; }
.btn-success { background: #27ae60; color: #fff; border-color: #27ae60; }
.btn-success:hover { background: #219a52; border-color: #219a52; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-ghost { background: transparent; border-color: transparent; color: #666; }
.btn-ghost:hover { background: #f0f0f0; color: #333; }

/* ── Tags ── */
.tag-badge {
  display: inline-block; padding: 1px 7px; font-size: 10px; font-weight: 600;
  background: #f0f0f0; color: #555; border-radius: 3px; margin-right: 3px;
  border: 1px solid #ddd;
}
.tag-input-wrap { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag-input-wrap .tag-badge { cursor: pointer; }
.tag-input-wrap .tag-badge:hover { background: #e0e0e0; border-color: #bbb; }
.tag-input-wrap input { border: 1px solid #d0d0d0; border-radius: 3px; padding: 2px 6px; font-size: 11px; width: 80px; outline: none; }
.tag-input-wrap input:focus { border-color: #888; }

/* ── Card ── */
.card {
  background: #fff; border: 1px solid #e0e0e0; padding: 14px 16px;
  margin-bottom: 12px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* ── Tables ── */
table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  background: #fff; border-radius: 6px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid #e0e0e0;
}
th, td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid #eee;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px;
}
th {
  background: #1a3c6e; color: #fff; font-weight: 600; font-size: 11px;
  letter-spacing: 0.3px;
  position: sticky; top: 0; z-index: 1;
}
tr:hover td { background: #f8f8f8; }
th.cb, td.cb { width: 30px; text-align: center; padding: 4px; }

/* ── Status Badges ── */
.st {
  display: inline-block; padding: 2px 10px; font-size: 11px; font-weight: 600;
  border-radius: 10px; letter-spacing: 0.2px; line-height: 1.4;
}
.st-draft, .st-草稿 { background: #f0f0f0; color: #888; }
.st-active, .st-进行中, .st-running, .st-运行中 { background: #d5f5e3; color: #1e8449; }
.st-launching, .st-启动中 { background: #fef9e7; color: #b7950b; }
.st-stopped, .st-已停机 { background: #fbeee6; color: #ca6f1e; }
.st-terminated, .st-已终止 { background: #fadbd8; color: #c0392b; }
.st-completed, .st-已完成 { background: #e8f4fd; color: #2e86c1; }
.st-pending, .st-待创建 { background: #f4f4f4; color: #aaa; }
.st-scheduled, .st-定时中 { background: #f4ecf7; color: #7d3c98; }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-top: 12px; font-size: 12px; color: #888;
  padding: 8px 0;
}
.pagination button { padding: 5px 12px; border-radius: 4px; }
.pagination button:disabled { opacity: 0.3; cursor: default; }
.pagination .pg-info { font-weight: 500; color: #555; }

/* ── Forms ── */
.form-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.form-row label { min-width: 90px; font-size: 12px; color: #666; text-align: right; flex-shrink: 0; font-weight: 500; }
.form-row input, .form-row select {
  flex: 1; padding: 7px 10px; background: #fff; border: 1px solid #d0d0d0;
  border-radius: 4px; color: #333; font-size: 12px; outline: none; transition: all .15s;
}
.form-row input:focus, .form-row select:focus { border-color: #888; box-shadow: 0 0 0 2px rgba(0,0,0,.05); }
textarea.config-editor {
  width: 100%; min-height: 150px; padding: 8px 10px; background: #fff;
  border: 1px solid #d0d0d0; border-radius: 4px;
  color: #333; font-family: "SF Mono", Consolas, "Courier New", monospace; font-size: 12px;
  resize: vertical; outline: none; tab-size: 2; display: none;
}
.form-section {
  margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: #333;
  padding-bottom: 5px; border-bottom: 2px solid #e0e0e0;
}

/* ── CodeMirror overrides ── */
.CodeMirror {
  border: 1px solid #d0d0d0; border-radius: 4px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 12px; height: auto; min-height: 120px;
}
.CodeMirror-focused { border-color: #888; }
.CodeMirror.inherited { background: #fafaf2; border-color: #e0ddc0; }
.CodeMirror.inherited .CodeMirror-gutters { background: #f0efd8; }
.cm-wrap { margin-bottom: 6px; }

/* ── Field wraps ── */
.field-wrap { position: relative; display: flex; flex: 1; gap: 4px; align-items: center; }
.field-wrap input.inherited { background: #fafaf2; border-color: #e0ddc0; }
.field-wrap .reset-btn {
  padding: 0 4px; font-size: 15px; color: #bbb; cursor: pointer;
  border: none; background: none; line-height: 1; display: none; transition: color .15s;
}
.field-wrap .reset-btn.visible { display: inline-block; }
.field-wrap .reset-btn:hover { color: #e67e22; }

/* ── Instance Fields Editor ── */
.ifields-row { display: flex; gap: 6px; margin-bottom: 4px; align-items: center; }
.ifields-row input[type="text"] { padding: 5px 8px; border: 1px solid #d0d0d0; border-radius: 4px; font-size: 12px; outline: none; transition: all .15s; }
.ifields-row input[type="text"]:focus { border-color: #888; }
.ifields-row input[type="checkbox"] { margin: 0 2px; width: 15px; height: 15px; accent-color: #e67e22; }
.ifields-row input[type="text"]:first-of-type { width: 100px; }
.ifields-row input[type="text"]:nth-of-type(2) { flex: 1; }

/* ── jspreadsheet ── */
.jcontextmenu { z-index: 200 !important; }

/* ── Edit Panel ── */
.edit-panel-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); display: flex; z-index: 100; justify-content: center; align-items: stretch; }
.edit-panel { background: #fff; border-left: 1px solid #ddd; width: 800px; max-width: 95vw; height: 100vh; display: flex; flex-direction: column; overflow: hidden; margin-left: auto; border-radius: 0; }
.edit-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid #e0e0e0; background: #fafafa; }
.edit-panel-header h3 { font-size: 15px; font-weight: 700; color: #333; }
.edit-panel-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.edit-panel-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid #e0e0e0; background: #fafafa; }

/* ── Breadcrumb ── */
.breadcrumb { font-size: 12px; color: #999; margin-bottom: 12px; }
.breadcrumb a { color: #e67e22; text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; color: #d35400; }
.breadcrumb span { margin: 0 6px; color: #ccc; }

/* ── jspreadsheet overrides ── */
.jss_container { border: 1px solid #e0e0e0 !important; border-radius: 4px !important; }
.jss_container .jss_content { font-family: "SF Mono", Consolas, "Courier New", monospace !important; font-size: 12px !important; }
.jss thead td { font-family: -apple-system, "Segoe UI", system-ui, sans-serif !important; font-size: 11px !important; font-weight: 600 !important; }

/* ── Info grid ── */
.info-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12px;
  margin-bottom: 12px; padding: 12px 16px; background: #fff; border: 1px solid #e0e0e0;
  border-radius: 6px;
}
.info-grid .lbl { color: #888; text-align: right; font-weight: 500; }
.info-grid .val { color: #333; }

.sel-info { font-size: 12px; color: #e67e22; margin-left: 8px; font-weight: 600; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ── Form card ── */
.form-card {
  background: #fff; border: 1px solid #e0e0e0; padding: 18px 20px;
  border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.form-actions {
  margin-top: 16px; display: flex; gap: 8px; padding-top: 14px; border-top: 1px solid #e0e0e0;
}

/* ── Table links ── */
table a { color: #e67e22; text-decoration: none; font-weight: 500; }
table a:hover { text-decoration: underline; color: #d35400; }

/* ── Modal Dialog ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.modal-box {
  background: #fff; border-radius: 8px; padding: 24px 28px; min-width: 340px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25); animation: modalIn 0.15s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Toast ── */
.toast-container {
  position: fixed; top: 56px; right: 16px; z-index: 3000;
  display: flex; flex-direction: column; gap: 6px;
}
.toast {
  padding: 10px 18px; font-size: 12px; color: #fff;
  border-radius: 6px; animation: toastIn .25s ease-out;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.toast-success { background: #27ae60; }
.toast-error { background: #c0392b; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Batch bar (selected items) ── */
.batch-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: #fff8f0; border: 1px solid #f0d0a0; border-radius: 6px;
  margin-bottom: 10px; font-size: 12px; color: #b45309;
}
.batch-bar .batch-count { font-weight: 700; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 40px 20px; color: #bbb;
  font-size: 14px;
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 10px; display: block; }

/* ── Table wrapper ── */
.table-wrapper { overflow-x: auto; }
