:root {
  --bg: #f5fafb;
  --surface: #ffffff;
  --ink: #21343c;
  --muted: #6b818c;
  --line: #e3edef;

  --turquoise: #1fb6b0;
  --turquoise-dark: #149b96;
  --turquoise-soft: #dff4f2;
  --orange: #f08a3c;
  --orange-soft: #fdeede;
  --red: #e0594f;
  --red-soft: #fbe6e4;

  --radius: 14px;
  --shadow: 0 6px 22px rgba(33, 52, 60, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f0f8f8 0%, var(--bg) 320px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--turquoise-dark); }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand .logo { height: 34px; width: auto; display: block; }
.brand-text { font-weight: 700; font-size: 1.1rem; color: var(--turquoise-dark); }
.app-name { font-weight: 600; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; }
.site-nav a { margin-left: 18px; text-decoration: none; font-weight: 600; color: var(--turquoise-dark); }
.site-nav a:hover { color: var(--orange); }

/* Layout */
.container { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 34px 24px 56px; }
.site-footer { text-align: center; color: var(--muted); padding: 20px; font-size: .85rem; border-top: 1px solid var(--line); background: var(--surface); }

h1 { font-size: 1.8rem; margin: 0 0 6px; }
.lead, .subtitle { color: var(--muted); margin-top: 0; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.muted { color: var(--muted); }

/* Hero + tool cards */
.hero { text-align: center; margin: 8px 0 30px; }
.hero h1 { font-size: 2.2rem; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.tool-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s ease;
  border-top: 4px solid var(--turquoise);
}
.tool-card:hover { transform: translateY(-3px); }
.tool-merge { border-top-color: var(--turquoise); }
.tool-split { border-top-color: var(--orange); }
.tool-icon { flex: 0 0 auto; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 12px; background: var(--turquoise-soft); color: var(--turquoise-dark); }
.tool-split .tool-icon { background: var(--orange-soft); color: var(--orange); }
.tool-icon svg { width: 30px; height: 30px; }
.tool-text { display: flex; flex-direction: column; gap: 3px; }
.tool-name { font-weight: 700; font-size: 1.15rem; }
.tool-desc { color: var(--muted); font-size: .92rem; }

/* Buttons */
.btn {
  display: inline-block; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: .95rem;
  padding: 10px 18px; border-radius: 10px; text-decoration: none;
}
.btn:hover { border-color: var(--turquoise); }
.btn-primary { background: var(--turquoise); border-color: var(--turquoise); color: #fff; }
.btn-primary:hover { background: var(--turquoise-dark); border-color: var(--turquoise-dark); }
.btn-primary[disabled] { background: #c4d6d8; border-color: #c4d6d8; cursor: not-allowed; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; padding: 7px 13px; font-size: .85rem; }
.btn-danger:hover { background: #c8483f; }
.btn.block { display: block; width: 100%; text-align: center; }

/* Dropzone */
.dropzone {
  border: 2px dashed #b8d8d6; border-radius: var(--radius); background: var(--surface);
  padding: 40px 20px; text-align: center; transition: background .12s, border-color .12s;
}
.dropzone.drag { border-color: var(--turquoise); background: var(--turquoise-soft); }
.dz-title { font-weight: 600; margin: 0 0 4px; }
.dz-or { color: var(--muted); margin: 4px 0 12px; }

/* Merge layout */
.merge-layout { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.list-col {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: sticky; top: 20px;
}
.list-col h2 { font-size: 1.05rem; margin: 0 0 10px; }
.file-list { list-style: none; margin: 0 0 14px; padding: 0; max-height: 320px; overflow: auto; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 7px; font-size: .9rem; }
.file-list li.empty { color: var(--muted); justify-content: center; border-style: dashed; }
.file-list .fn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .pg { color: var(--muted); font-size: .8rem; }
.file-list .rm { border: none; background: var(--red-soft); color: var(--red); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1; }
.field-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.text-input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: .95rem; margin-bottom: 12px; }
.text-input:focus { outline: 2px solid var(--turquoise-soft); border-color: var(--turquoise); }

/* Results / messages */
.result { margin-top: 14px; }
.result .ok, .file-name { color: var(--turquoise-dark); font-weight: 600; }
.error { color: var(--red); font-weight: 600; min-height: 1.1em; margin: 10px 0; }
.page-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.page-list li a { display: block; padding: 9px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; text-decoration: none; }
.page-list li a:hover { border-color: var(--orange); }
.file-name { margin: 14px 0; }
#splitBtn { margin-bottom: 6px; }

/* Login */
.login-card { max-width: 380px; margin: 30px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.login-form input { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; margin-top: 5px; font-size: .95rem; }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .9rem; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { background: var(--turquoise-soft); color: var(--turquoise-dark); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.admin-table .nowrap { white-space: nowrap; }
.admin-table .break { word-break: break-all; }
.admin-table .ua { max-width: 220px; color: var(--muted); font-size: .8rem; word-break: break-word; }
.badge { padding: 2px 9px; border-radius: 20px; font-size: .78rem; font-weight: 700; }
.badge-merge { background: var(--turquoise-soft); color: var(--turquoise-dark); }
.badge-split { background: var(--orange-soft); color: var(--orange); }
.file-links { list-style: none; margin: 8px 0 0; padding: 0; }
.file-links li { padding: 3px 0; font-size: .85rem; }
.role { display: inline-block; min-width: 50px; font-size: .72rem; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.role-output { color: var(--turquoise-dark); }
.size { color: var(--muted); font-size: .78rem; }

@media (max-width: 720px) {
  .merge-layout { grid-template-columns: 1fr; }
  .list-col { position: static; }
}
