:root {
  --ink: #17201e;
  --muted: #687370;
  --line: #dce3df;
  --soft: #f3f6f4;
  --paper: #ffffff;
  --cream: #f4f1e9;
  --navy: #162927;
  --green: #2f765e;
  --green-dark: #245d4b;
  --green-pale: #e4f0e9;
  --orange: #d97737;
  --red: #c54a4a;
  --yellow: #bc8a21;
  --shadow: 0 22px 70px rgba(20, 42, 36, .11);
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; }
button, input, textarea, select { font: inherit; }
button, a, select, label { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.public-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 25%, rgba(47, 118, 94, .11) 0 1px, transparent 2px) 0 0 / 26px 26px,
    var(--cream);
}

.public-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; }
.public-header { height: 92px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 18px; font-weight: 800; letter-spacing: -.03em; }
.brand-mark { position: relative; width: 29px; height: 29px; display: inline-block; background: var(--navy); transform: rotate(-6deg); }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border: 2px solid #fff; }
.brand-mark span { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #d8e8b0; right: -3px; top: -3px; }
.brand-light { color: white; }
.brand-light .brand-mark { background: #f4f1e9; }
.brand-light .brand-mark::after { border-color: var(--navy); }
.admin-link, .back-link { display: inline-flex; align-items: center; gap: 5px; color: #4e5a57; font-size: 13px; font-weight: 700; }
.admin-link { border-bottom: 1px solid #b8c1bd; padding: 7px 0; }
.admin-link:hover, .back-link:hover { color: var(--green); }

.public-main { display: grid; grid-template-columns: .84fr 1.16fr; gap: clamp(48px, 7vw, 110px); align-items: center; min-height: calc(100vh - 154px); padding: 28px 0 60px; }
.intro { padding-left: clamp(0px, 2vw, 24px); }
.eyebrow, .form-kicker { text-transform: uppercase; letter-spacing: .15em; font-size: 11px; font-weight: 800; color: var(--green); }
.eyebrow { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; }
.eyebrow > span { width: 27px; height: 2px; background: var(--green); }
.intro h1 { margin: 0; font-size: clamp(48px, 5.2vw, 75px); line-height: .99; letter-spacing: -.065em; font-weight: 700; }
.intro h1 em { color: var(--green); font-style: normal; position: relative; }
.intro h1 em::after { content: ""; position: absolute; height: 5px; bottom: -3px; left: 3px; right: -4px; background: #d3de9d; transform: rotate(-2deg); z-index: -1; }
.intro-copy { max-width: 510px; margin: 28px 0 36px; color: #58635f; font-size: 16px; line-height: 1.75; }
.process-list { border-top: 1px solid #cfd5cf; max-width: 480px; }
.process-item { display: grid; grid-template-columns: 44px 1fr; gap: 15px; align-items: center; padding: 14px 0; border-bottom: 1px solid #cfd5cf; font-size: 13px; font-weight: 600; }
.process-item b { color: var(--green); font-size: 11px; letter-spacing: .1em; }
.availability { display: flex; align-items: center; gap: 12px; margin-top: 28px; }
.availability > span:last-child { display: flex; flex-direction: column; }
.availability b { font-size: 12px; }
.availability small { color: var(--muted); margin-top: 2px; font-size: 11px; }
.pulse { width: 10px; height: 10px; background: #5e9d74; border-radius: 50%; box-shadow: 0 0 0 6px rgba(94, 157, 116, .14); }

.form-panel { background: var(--paper); padding: clamp(28px, 4vw, 50px); box-shadow: var(--shadow); border-top: 5px solid var(--navy); }
.form-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 31px; }
.form-heading h2, .success-state h2 { margin: 8px 0 0; font-size: clamp(23px, 2.2vw, 31px); line-height: 1.15; letter-spacing: -.04em; }
.required-note { color: #8c9692; font-size: 10px; white-space: nowrap; margin-top: 4px; }
.field { margin-bottom: 22px; }
.field label, fieldset legend { display: block; font-size: 12px; font-weight: 800; margin-bottom: 8px; }
sup { color: var(--red); font-size: 10px; }
.optional { color: #98a09d; font-weight: 500; margin-left: 6px; }
input[type="text"], input[type="password"], textarea, .filter-form select {
  width: 100%; border: 1px solid var(--line); border-radius: 2px; background: #fbfcfb; color: var(--ink); outline: none; transition: border .2s, box-shadow .2s, background .2s;
}
input[type="text"], input[type="password"] { height: 48px; padding: 0 14px; }
textarea { padding: 13px 14px; min-height: 112px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #a7afac; }
input:focus, textarea:focus, select:focus { background: white; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 118, 94, .1); }
.field-hint { display: flex; justify-content: space-between; margin-top: 6px; color: #939c98; font-size: 9px; }
.priority-field { margin: 0 0 22px; border: 0; padding: 0; }
.priority-options { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); }
.priority-option { min-height: 65px; padding: 12px 9px; display: flex; align-items: center; gap: 8px; cursor: pointer; border-right: 1px solid var(--line); background: #fbfcfb; transition: background .2s; }
.priority-option:last-child { border-right: 0; }
.priority-option input { position: absolute; opacity: 0; pointer-events: none; }
.priority-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #9eaaa6; box-shadow: 0 0 0 3px transparent; }
.priority-option > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.priority-option b { font-size: 11px; line-height: 1.3; }
.priority-option small { color: #88928e; font-size: 8px; white-space: nowrap; margin-top: 3px; }
.priority-option:has(input:checked) { background: #edf5f1; box-shadow: inset 0 -2px var(--green); }
.priority-option:has(input:checked) .priority-dot { background: var(--green); box-shadow: 0 0 0 3px #d6e7df; }
.priority-option.high:has(input:checked) { background: #fff6eb; box-shadow: inset 0 -2px var(--orange); }
.priority-option.high:has(input:checked) .priority-dot { background: var(--orange); box-shadow: 0 0 0 3px #f9dfc7; }
.priority-option.urgent:has(input:checked) { background: #fff0f0; box-shadow: inset 0 -2px var(--red); }
.priority-option.urgent:has(input:checked) .priority-dot { background: var(--red); box-shadow: 0 0 0 3px #f3d2d2; }
.dropzone { min-height: 82px; border: 1px dashed #aebbb5; display: flex !important; align-items: center; justify-content: center; gap: 14px; background: #f9fbfa; cursor: pointer; transition: .2s; margin: 0 !important; }
.dropzone:hover, .dropzone.dragging { border-color: var(--green); background: #f0f6f3; }
.dropzone > span:last-child { display: flex; flex-direction: column; }
.dropzone b { font-size: 11px; }
.dropzone small { color: #8c9692; font-weight: 500; font-size: 9px; margin-top: 4px; }
.upload-icon { width: 40px; height: 40px; display: grid; place-items: center; color: var(--green); background: var(--green-pale); }
.paste-status { display: block; min-height: 0; max-height: 0; overflow: hidden; margin-top: 0; color: var(--green); font-size: 10px; font-weight: 700; opacity: 0; transition: max-height .2s, margin .2s, opacity .2s; }
.paste-status.visible { max-height: 25px; margin-top: 7px; opacity: 1; }
.paste-status.error { color: var(--red); }
.file-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.preview-item { position: relative; height: 58px; overflow: hidden; border: 1px solid var(--line); background: var(--soft); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item button { position: absolute; right: 3px; top: 3px; width: 20px; height: 20px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: rgba(20, 32, 29, .82); color: #fff; font-size: 13px; }
.primary-button, .secondary-button, .create-button { border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; cursor: pointer; transition: transform .15s, background .2s, opacity .2s; }
.primary-button { width: 100%; min-height: 52px; padding: 0 22px; color: white; background: var(--green); font-size: 12px; letter-spacing: .01em; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:active, .secondary-button:active, .create-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.secondary-button { min-height: 44px; padding: 0 20px; border: 1px solid var(--line); background: white; color: var(--ink); }
.form-message { padding: 11px 13px; margin-bottom: 14px; font-size: 11px; font-weight: 600; }
.form-message.error { color: #9c3030; border-left: 3px solid var(--red); background: #fff0f0; }
.success-state { text-align: center; padding: 70px 10px; }
.success-state p { color: var(--muted); max-width: 410px; line-height: 1.7; margin: 16px auto 25px; font-size: 13px; }
.success-icon { width: 70px; height: 70px; display: grid; place-items: center; margin: 0 auto 24px; color: var(--green); background: var(--green-pale); border-radius: 50%; }
.public-footer { min-height: 62px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid rgba(23, 32, 30, .12); color: #808a86; font-size: 10px; }

/* Login */
.login-page { min-height: 100vh; background: white; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(330px, 42%) 1fr; }
.login-aside { background: var(--navy); color: white; padding: clamp(34px, 5vw, 72px); display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-aside::after { content: ""; position: absolute; width: 360px; height: 360px; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; right: -160px; bottom: 40px; box-shadow: 0 0 0 65px rgba(255,255,255,.025), 0 0 0 130px rgba(255,255,255,.018); }
.login-aside > div { position: relative; z-index: 1; max-width: 480px; }
.form-kicker.light { color: #bad0c7; }
.login-aside h1 { margin: 17px 0; font-size: clamp(40px, 4.8vw, 68px); line-height: 1.02; letter-spacing: -.06em; }
.login-aside p { color: #aebeba; font-size: 14px; line-height: 1.75; max-width: 420px; }
.login-aside small { color: #82928e; font-size: 10px; }
.login-main { display: grid; place-items: center; padding: 40px; background: #fbfcfb; }
.login-form { width: min(390px, 100%); }
.login-form .back-link { margin-bottom: 70px; }
.login-form h2 { margin: 10px 0 8px; font-size: 36px; letter-spacing: -.05em; }
.login-form > p { color: var(--muted); font-size: 13px; line-height: 1.65; margin-bottom: 32px; }
.login-form .field { margin-bottom: 16px; }

/* Admin */
.admin-page { min-height: 100vh; background: #f4f6f5; }
.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: white; padding: 30px 20px 22px; display: flex; flex-direction: column; }
.sidebar .brand { padding: 0 10px; }
.sidebar-nav { margin-top: 48px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a { height: 43px; padding: 0 12px; display: flex; align-items: center; gap: 11px; color: #aabcb7; font-size: 12px; font-weight: 700; }
.sidebar-nav a:hover { color: white; background: rgba(255,255,255,.05); }
.sidebar-nav a.active { color: white; background: rgba(255,255,255,.09); box-shadow: inset 3px 0 #92b8a6; }
.sidebar-nav a > span { margin-left: auto; min-width: 20px; height: 20px; display: grid; place-items: center; background: #d5e7dd; color: var(--navy); border-radius: 10px; font-size: 9px; }
.sidebar-bottom { margin-top: auto; }
.telegram-state { padding: 14px 10px 18px; display: flex; gap: 11px; border-bottom: 1px solid rgba(255,255,255,.1); }
.telegram-state > span:last-child { display: flex; flex-direction: column; }
.telegram-state b { font-size: 11px; }
.telegram-state small { max-width: 130px; margin-top: 3px; color: #869a95; line-height: 1.4; font-size: 8px; }
.telegram-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: #338fc6; font-weight: 800; transform: rotate(-20deg); }
.logout-button { width: 100%; border: 0; background: none; color: #91a39e; text-align: left; padding: 17px 11px 3px; font-size: 11px; cursor: pointer; }
.logout-button:hover { color: white; }
.admin-main { min-width: 0; padding: 44px clamp(24px, 4vw, 64px) 70px; }
.admin-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 32px; }
.breadcrumb { color: #8d9793; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; }
.admin-header h1 { margin: 7px 0 5px; font-size: 37px; letter-spacing: -.05em; }
.admin-header p { margin: 0; color: var(--muted); font-size: 12px; }
.create-button { min-height: 42px; padding: 0 18px; color: white; background: var(--green); font-size: 11px; }
.create-button:hover { background: var(--green-dark); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: white; margin-bottom: 24px; }
.stat-card { position: relative; min-height: 116px; padding: 20px 22px; border-right: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; }
.stat-card:last-child { border-right: 0; }
.stat-card:hover, .stat-card.active { background: #f8faf9; }
.stat-card.active::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 3px; background: var(--navy); }
.stat-card > span { color: #697470; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat-card b { grid-row: span 2; font-size: 38px; line-height: 1; letter-spacing: -.06em; }
.stat-card small { align-self: end; color: #9aa39f; font-size: 9px; }
.stat-new b { color: var(--green); }
.stat-work b { color: var(--yellow); }
.stat-done b { color: #6c8580; }
.tickets-section { background: white; border: 1px solid var(--line); }
.tickets-toolbar { min-height: 78px; padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.tickets-toolbar h2 { font-size: 16px; margin: 0 0 3px; letter-spacing: -.025em; }
.tickets-toolbar > div > span { color: #98a19e; font-size: 9px; }
.filter-form { display: flex; align-items: center; gap: 9px; }
.filter-form label { color: #8a9490; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.filter-form select { width: 120px; height: 35px; padding: 0 28px 0 10px; font-size: 10px; }
.ticket-row { border-bottom: 1px solid #e8ecea; }
.ticket-row:last-child { border-bottom: 0; }
.ticket-row details > summary { min-height: 88px; display: grid; grid-template-columns: 3px minmax(280px, 1fr) auto 130px 18px; align-items: center; gap: 18px; padding: 0 20px 0 0; cursor: pointer; list-style: none; }
.ticket-row details > summary::-webkit-details-marker { display: none; }
.ticket-row details > summary:hover { background: #fafcfb; }
.priority-line { height: 88px; background: #9ca7a3; }
.priority-line.priority-medium { background: #6d8f81; }
.priority-line.priority-high { background: var(--orange); }
.priority-line.priority-urgent { background: var(--red); }
.ticket-main-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ticket-meta { display: flex; gap: 10px; align-items: center; }
.ticket-meta b { color: var(--green); font-size: 9px; letter-spacing: .06em; }
.ticket-meta time { color: #9ba49f; font-size: 8px; }
.ticket-main-info strong { font-size: 13px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.ticket-excerpt { color: #7d8783; font-size: 9px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; max-width: 580px; }
.ticket-badges { display: flex; align-items: center; gap: 9px; }
.priority-badge { padding: 5px 8px; color: #53605c; background: #edf0ef; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.priority-badge.medium { color: #436d5c; background: #e4efea; }
.priority-badge.high { color: #9b561e; background: #fceedf; }
.priority-badge.urgent { color: #a63b3b; background: #f9e4e4; }
.attachment-count { display: inline-flex; align-items: center; gap: 3px; color: #87918d; font-size: 9px; }
.status-select { width: 122px; height: 34px; border: 1px solid var(--line); border-radius: 2px; outline: none; padding: 0 25px 0 9px; background: white; font-size: 9px; font-weight: 700; }
.status-select.status-new { color: var(--green); }
.status-select.status-in_progress { color: #9b711c; background: #fffaf0; }
.status-select.status-resolved { color: #687875; background: #f4f6f5; }
.chevron { color: #9aa39f; transition: transform .2s; }
details[open] .chevron { transform: rotate(90deg); }
.ticket-details { background: #f8faf9; border-top: 1px solid #e7ebe9; padding: 24px 41px; display: grid; grid-template-columns: minmax(300px, 1.6fr) minmax(170px, .7fr); gap: 24px 50px; }
.detail-label { color: #8e9894; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; }
.ticket-details p { white-space: pre-wrap; font-size: 11px; line-height: 1.7; margin: 7px 0 0; }
.ticket-side-details { display: grid; gap: 18px; align-content: start; }
.screenshots { grid-column: 1 / -1; }
.screenshot-grid { display: grid; grid-template-columns: repeat(3, minmax(120px, 210px)); gap: 10px; margin-top: 8px; }
.screenshot-grid a { height: 115px; border: 1px solid var(--line); background: white; overflow: hidden; }
.screenshot-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.screenshot-grid a:hover img { transform: scale(1.035); }
.empty-state { min-height: 300px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; color: var(--green); background: var(--green-pale); border-radius: 50%; }
.empty-state h3 { font-size: 15px; margin: 14px 0 4px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 10px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 13px 18px; color: white; background: var(--navy); box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 11px; font-weight: 700; }
.toast.error { background: #9c3737; }

@media (max-width: 1020px) {
  .public-main { grid-template-columns: .72fr 1.28fr; gap: 35px; }
  .intro h1 { font-size: 53px; }
  .process-list { display: none; }
  .admin-layout { grid-template-columns: 74px 1fr; }
  .sidebar { padding-inline: 12px; }
  .sidebar .brand > span:last-child, .sidebar-nav a:not(.active), .sidebar-nav a.active { font-size: 0; }
  .sidebar .brand { justify-content: center; padding: 0; }
  .sidebar-nav a { justify-content: center; padding: 0; }
  .sidebar-nav a > span { position: absolute; margin: -26px 0 0 26px; font-size: 8px; }
  .telegram-state, .logout-button { display: none; }
  .ticket-row details > summary { grid-template-columns: 3px minmax(200px, 1fr) 125px 18px; }
  .ticket-badges { display: none; }
}

@media (max-width: 760px) {
  .public-shell { width: min(100% - 28px, 620px); }
  .public-header { height: 72px; }
  .public-main { display: block; padding: 30px 0 42px; }
  .intro { padding: 0; }
  .intro h1 { font-size: clamp(45px, 13vw, 66px); }
  .intro-copy { margin-bottom: 26px; }
  .availability { margin-bottom: 38px; }
  .form-panel { padding: 28px 20px; }
  .priority-options { grid-template-columns: 1fr 1fr; }
  .priority-option:nth-child(2) { border-right: 0; }
  .priority-option:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .public-footer { flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; }
  .login-shell { display: block; }
  .login-aside { min-height: 230px; padding: 30px; }
  .login-aside > div { margin-top: 55px; }
  .login-aside h1 { font-size: 39px; }
  .login-aside p, .login-aside small { display: none; }
  .login-main { min-height: calc(100vh - 230px); padding: 45px 25px; place-items: start center; }
  .login-form .back-link { margin-bottom: 42px; }
  .admin-layout { display: block; }
  .sidebar { position: static; width: 100%; height: 62px; padding: 0 18px; flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar .brand > span:last-child { display: inline; font-size: 16px; }
  .sidebar .brand { justify-content: start; }
  .sidebar-nav { margin: 0; flex-direction: row; }
  .sidebar-nav a { display: none; }
  .sidebar-nav a.active { display: flex; width: 42px; }
  .sidebar-nav a.active span { margin: -27px 0 0 26px; }
  .sidebar-bottom { display: none; }
  .admin-main { padding: 29px 14px 50px; }
  .admin-header { align-items: start; }
  .admin-header h1 { font-size: 31px; }
  .admin-header p { display: none; }
  .create-button { width: 42px; padding: 0; font-size: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:nth-child(2) { border-right: 0; }
  .stat-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .tickets-toolbar { align-items: flex-start; flex-direction: column; }
  .ticket-row details > summary { min-height: 100px; grid-template-columns: 3px minmax(120px, 1fr) 112px 14px; gap: 10px; padding-right: 10px; }
  .priority-line { height: 100px; }
  .ticket-excerpt { max-width: 280px; }
  .status-select { width: 110px; }
  .ticket-details { grid-template-columns: 1fr; padding: 22px 24px; gap: 20px; }
  .screenshots { grid-column: auto; }
  .screenshot-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 460px) {
  .admin-link { font-size: 0; }
  .admin-link svg { width: 21px; height: 21px; }
  .form-heading { display: block; }
  .required-note { display: block; margin-top: 8px; }
  .priority-option { padding-inline: 8px; }
  .stats-grid { gap: 0; }
  .stat-card { padding: 17px; min-height: 100px; }
  .stat-card b { font-size: 32px; }
  .ticket-row details > summary { grid-template-columns: 3px minmax(120px, 1fr) 98px; }
  .chevron { display: none; }
  .status-select { width: 96px; font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
