:root {
  --navy: #10243d;
  --blue: #235d9f;
  --steel: #4f7fae;
  --cyan: #21a8c7;
  --light: #f4f7fb;
  --text: #1f3147;
  --muted: #65758a;
  --border: #d8e1ec;
  --danger: #b34242;
  --success: #1e7f58;
  --shadow: 0 18px 55px rgba(16, 36, 61, 0.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(33, 168, 199, 0.2), transparent 36%),
    linear-gradient(135deg, #eef5ff 0%, #f8fbff 50%, #edf3fa 100%);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", Arial, sans-serif;
}

.hidden { display: none !important; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
h1 { margin: 0; color: var(--navy); font-size: clamp(26px, 3vw, 34px); line-height: 1.12; }
h2 { margin: 0 0 16px; color: var(--navy); }
p { margin: 6px 0 0; color: #46576b; }

.login-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(460px, 94vw);
  padding: 34px;
  border: 1px solid rgba(216, 225, 236, 0.92);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}
.brand-mark {
  display: grid;
  width: 62px;
  height: 62px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.05em;
}
.login-copy { margin: 12px 0 24px; }
.login-form { display: grid; gap: 14px; }
.login-error {
  min-height: 21px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.app-shell {
  display: grid;
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px 12px;
}
.header-actions { display: flex; gap: 10px; align-items: center; }
.layout {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(330px, 0.42fr) minmax(430px, 0.58fr);
  gap: 20px;
  padding: 0 28px 12px;
  overflow: hidden;
  align-items: stretch;
}
.card, .entity-panel, dialog {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card {
  min-height: 0;
  padding: 20px;
}
.parameters, .right-column, .data-setup { min-height: 0; }
.parameters, .data-setup { height: 100%; }
.right-column {
  display: grid;
  overflow: hidden;
}
label {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 10px 0;
  color: #263b54;
  font-weight: 750;
}
input {
  width: 100%;
  border: 1px solid #c7d3e0;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(33, 168, 199, 0.13);
}
input[readonly] { background: #f1f5f9; color: #526173; }
button {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--steel));
  color: #fff;
  cursor: pointer;
  font: 800 14px "Segoe UI", Arial, sans-serif;
  padding: 11px 16px;
  box-shadow: 0 8px 18px rgba(35, 93, 159, 0.2);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
button:hover:not(:disabled) { filter: brightness(1.04); transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.5; box-shadow: none; }
button.secondary { background: #607589; }
button.ghost {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: none;
}
.app-header button.ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--navy);
}
button.danger { background: linear-gradient(135deg, var(--danger), #d56161); }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-heading h2 { margin: 0; }
.date-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.data-setup { overflow: auto; }
.data-setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.setup-group {
  border: 1px solid #e3ebf4;
  border-radius: 14px;
  padding: 14px;
  background: #f8fbff;
}
.setup-group h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 16px;
}
.setup-group label {
  grid-template-columns: 125px minmax(0, 1fr);
  margin: 8px 0;
}
.sizes-group { margin-top: 16px; }
.sizes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

.entity-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.logs-dialog {
  --logs-left: auto;
  --logs-width: min(460px, 34vw);
  --logs-top: 5dvh;
  --logs-height: 90dvh;
  position: fixed;
  inset: var(--logs-top) 2vw auto var(--logs-left);
  width: var(--logs-width);
  height: var(--logs-height);
  max-width: 96vw;
  max-height: 90dvh;
  min-width: 320px;
  min-height: 360px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  resize: both;
  z-index: 30;
}
.logs-dialog::backdrop { background: transparent; backdrop-filter: none; }
.logs-panel {
  display: grid;
  position: relative;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  cursor: move;
  user-select: none;
}
.logs-header h2 { color: #fff; margin: 0; }
.logs-panel pre {
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border-top: 1px solid #172337;
  background: #07111f;
  color: #9ef0bd;
  font: 13px/1.5 Consolas, monospace;
}
.logs-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  background: transparent;
}
.logs-resize-handle:hover { background: rgba(33, 168, 199, 0.18); }
.entity-dialog {
  position: fixed;
  top: 5dvh;
  left: 50%;
  width: min(1180px, 96vw);
  height: min(760px, 90dvh);
  max-height: 90dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transform: translateX(-50%);
  z-index: 20;
}
body.logs-open.entity-active .entity-dialog {
  left: 2vw;
  transform: none;
}
dialog { border: 0; }
dialog::backdrop { background: rgba(16, 35, 59, 0.58); backdrop-filter: blur(3px); }
.entity-panel {
  display: grid;
  height: 100%;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  box-shadow: none;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  padding: 18px 22px;
}
.panel-header h2 { color: #fff; margin: 0; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fbff;
}
.table-wrap { min-height: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td {
  border-bottom: 1px solid #e6edf5;
  padding: 11px 12px;
  text-align: center;
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf1f9;
  color: #1c3048;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tbody tr:hover { background: #f8fbff; }
td.file { font-family: Consolas, monospace; font-size: 13px; }
td.status { color: var(--success); font-weight: 800; }
a.download { color: var(--blue); font-weight: 800; text-decoration: none; }
a.download:hover { text-decoration: underline; }
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.muted { margin: 0; color: var(--muted); }
.pagination-controls { display: flex; align-items: center; gap: 12px; }
#pageStatus { color: var(--navy); font-weight: 800; }
#configDialog { width: min(900px, 92vw); padding: 0; }
dialog form { padding: 24px; }
.config-grid label { grid-template-columns: 170px minmax(0, 1fr); }
menu { display: flex; justify-content: flex-end; gap: 12px; padding: 0; margin: 20px 0 0; }
footer {
  padding: 0 28px 14px;
  color: var(--blue);
  font-weight: 800;
  text-align: center;
}
@media (max-width: 900px) {
  .data-setup-grid, .sizes-grid { grid-template-columns: 1fr; }
  body { overflow: auto; }
  .app-shell { min-height: 100dvh; height: auto; overflow: visible; }
  .layout { grid-template-columns: 1fr; overflow: visible; }
  .app-header { flex-direction: column; align-items: flex-start; }
  label { grid-template-columns: 1fr; gap: 6px; }
  .entity-dialog { left: 4vw; width: 92vw; height: 92dvh; transform: none; }
  .logs-dialog {
    inset: 4dvh 4vw auto 4vw;
    width: 92vw !important;
    height: 92dvh;
  }
}
