/* ============================================================
   GTFS Group — интерфейс оформления документов
   Светлая тема, крупные тач-зоны, всё читается с телефона.
   ============================================================ */

:root {
    --brand:        #635bff;
    --brand-dark:   #4b44db;
    --brand-soft:   #f0efff;

    --ink:          #0a2540;
    --ink-2:        #3c4257;
    --muted:        #6b7c93;
    --line:         #e3e8ee;
    --line-strong:  #cfd7df;

    --bg:           #f6f9fc;
    --card:         #ffffff;

    --ok:           #0e9f6e;
    --danger:       #df1b41;
    --danger-soft:  #fdf2f4;

    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  16px;

    --shadow-sm: 0 1px 2px rgba(10, 37, 64, .06), 0 1px 3px rgba(10, 37, 64, .04);
    --shadow-md: 0 4px 6px -1px rgba(10, 37, 64, .06), 0 12px 24px -8px rgba(10, 37, 64, .10);
    --shadow-lg: 0 8px 16px -4px rgba(10, 37, 64, .08), 0 24px 48px -12px rgba(10, 37, 64, .14);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
            "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.wrap { width: min(760px, 100% - 32px); margin: 0 auto; }
.wrap-wide { width: min(1180px, 100% - 32px); }

/* ------------------------------------------------------------ шапка */
.top {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.top .wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 650;
    font-size: 16px;
    letter-spacing: -.01em;
}
.brand:hover { color: var(--ink); }
.brand-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand) 0%, #8f7bff 100%);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -.02em;
    box-shadow: 0 2px 6px rgba(99, 91, 255, .35);
}
.brand-sub {
    color: var(--muted);
    font-size: 14px;
    padding-left: 12px;
    border-left: 1px solid var(--line);
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.top-link { color: var(--muted); font-size: 14px; font-weight: 500; }
.top-link:hover { color: var(--ink); }

main { padding: 28px 0 56px; }

@media (max-width: 560px) {
    .brand-sub { display: none; }
    main { padding: 18px 0 40px; }
}

/* ----------------------------------------------------------- карточки */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px;
    margin-bottom: 20px;
}
.card-narrow { max-width: 400px; margin: 8vh auto 0; }
.card-flat { box-shadow: none; }

@media (max-width: 560px) {
    .card { padding: 20px 18px; border-radius: var(--r-md); }
    .card-narrow { margin-top: 4vh; }
}

/* -------------------------------------------------------- типографика */
h1 {
    font-size: 26px;
    line-height: 1.25;
    letter-spacing: -.02em;
    margin: 0 0 8px;
    font-weight: 650;
}
h2 {
    font-size: 17px;
    letter-spacing: -.01em;
    margin: 0 0 16px;
    font-weight: 650;
}
.lead { color: var(--muted); margin: 0 0 24px; font-size: 15px; }
.note { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 14px 0 0; }

@media (max-width: 560px) {
    h1 { font-size: 22px; }
}

/* -------------------------------------------------------------- форма */
fieldset { border: 0; padding: 0; margin: 0 0 26px; }
fieldset:last-of-type { margin-bottom: 20px; }

legend {
    display: block;
    width: 100%;
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    padding: 0 0 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

.field { display: block; margin-bottom: 18px; }
.field > span {
    display: block;
    font-size: 14px;
    font-weight: 550;
    color: var(--ink-2);
    margin-bottom: 7px;
}
.field b { color: var(--danger); font-weight: 600; }

input[type=text],
input[type=password],
textarea,
select {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 16px;           /* 16px, иначе iOS зумит при фокусе */
    line-height: 1.4;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
}
input::placeholder, textarea::placeholder { color: #9aa8b8; }

input[type=text]:hover, textarea:hover, select:hover { border-color: #b9c3cf; }

input[type=text]:focus,
input[type=password]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(99, 91, 255, .18);
}

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

select {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7c93' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
@media (max-width: 640px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.hint { display: block; color: var(--muted); font-size: 13px; font-style: normal; margin-top: 6px; }
.err {
    display: block;
    color: var(--danger);
    font-size: 13px;
    font-style: normal;
    margin-top: 6px;
    font-weight: 500;
}
.field.has-error input,
.field.has-error textarea,
.field.has-error select { border-color: var(--danger); }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* --------------------------------------------------- живой расчёт сумм */
.calc {
    background: var(--brand-soft);
    border: 1px solid #dcd9ff;
    border-radius: var(--r-md);
    padding: 14px 16px;
    font-size: 14px;
}
.calc div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 4px 0;
}
.calc span { color: var(--ink-2); }
.calc b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------ кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--brand);
    color: #fff;
    border: 0;
    border-radius: var(--r-sm);
    padding: 13px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    min-height: 46px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(99, 91, 255, .32);
    transition: background .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--brand-dark); color: #fff; box-shadow: 0 4px 10px rgba(99, 91, 255, .34); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 3px rgba(99, 91, 255, .3); }
.btn-block { width: 100%; }
.btn-ghost {
    background: #fff;
    color: var(--ink-2);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: #f8fafc; color: var(--ink); box-shadow: var(--shadow-sm); }

@media (max-width: 560px) {
    .btn { width: 100%; }
    .btn-auto { width: auto; }
}

/* ---------------------------------------------------------- сообщения */
.alert {
    border-radius: var(--r-md);
    padding: 13px 15px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.45;
    display: flex;
    gap: 10px;
}
.alert-error {
    background: var(--danger-soft);
    color: #a4123a;
    border: 1px solid #f6cdd8;
}
.alert::before { content: "!"; font-weight: 700; }

/* -------------------------------------------------- готовые документы */
.files { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .files { grid-template-columns: 1fr; } }

.file {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px;
    color: var(--ink);
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s, transform .1s;
}
.file:hover {
    color: var(--ink);
    border-color: #c7c2ff;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.file-ico {
    flex: none;
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--danger);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
}
.file b { display: block; font-size: 15px; font-weight: 600; }
.file em { color: var(--muted); font-size: 13px; font-style: normal; }

/* ------------------------------------------------------------ таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl td { padding: 13px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.total-row td {
    border-top: 1px solid var(--ink);
    border-bottom: 0;
    font-weight: 650;
    padding-top: 14px;
}

.card.highlight {
    background: linear-gradient(180deg, #fbfaff 0%, #ffffff 60%);
    border-color: #ded9ff;
}
.total {
    font-size: 34px;
    line-height: 1.1;
    font-weight: 680;
    letter-spacing: -.02em;
    color: var(--brand);
    margin: 0 0 8px;
    font-variant-numeric: tabular-nums;
}
@media (max-width: 560px) {
    .total { font-size: 28px; }
    .tbl { font-size: 14px; }
}

.back { text-align: center; margin: 4px 0 0; }
.back a { font-size: 14px; font-weight: 500; }

/* ------------------------------------------------------------ подвал */
.bottom {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    padding: 24px 0 40px;
    border-top: 1px solid var(--line);
}

/* ============================================================ админка */
.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.admin-head h1 { margin: 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.stats div {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
}
.stats b {
    display: block;
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    margin-bottom: 2px;
}
.stats span { color: var(--muted); font-size: 13px; }

.search { display: flex; gap: 10px; align-items: center; }
.search input { flex: 1; min-width: 0; }
.search .btn { flex: none; padding: 13px 22px; }
.search .reset { color: var(--muted); font-size: 13px; flex: none; }

@media (max-width: 640px) {
    .stats { grid-template-columns: 1fr 1fr; }
    .stats div:last-child { grid-column: 1 / -1; }
    .search { flex-wrap: wrap; }
    .search input { flex: 1 1 100%; }
    .search .btn { width: auto; flex: 1; }
}

.scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.tbl-list { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl-list th {
    text-align: left;
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    padding: 0 14px 10px 0;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.tbl-list th.num { text-align: right; }
.tbl-list td { padding: 14px 14px 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl-list tr:last-child td { border-bottom: 0; }
.tbl-list .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-list .nowrap { white-space: nowrap; }
.tbl-list .strong { font-weight: 600; }

.doc-links { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

.badge {
    display: inline-block;
    background: var(--brand-soft);
    color: var(--brand-dark);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: -.01em;
    white-space: nowrap;
}

/* Таблица заявок на телефоне превращается в карточки */
@media (max-width: 760px) {
    .tbl-list thead { display: none; }
    .tbl-list, .tbl-list tbody, .tbl-list tr, .tbl-list td { display: block; width: 100%; }
    .tbl-list tr {
        border: 1px solid var(--line);
        border-radius: var(--r-md);
        padding: 14px;
        margin-bottom: 12px;
        box-shadow: var(--shadow-sm);
    }
    .tbl-list td {
        border: 0;
        padding: 5px 0;
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 2px 14px;
        align-items: baseline;
    }
    .tbl-list td::before {
        content: attr(data-label);
        grid-column: 1;
        color: var(--muted);
        font-size: 13px;
        text-align: left;
    }
    .tbl-list td > * { grid-column: 2; text-align: right; }
    .tbl-list td:first-child { padding-top: 0; }
    .tbl-list .num { text-align: right; }
    .doc-links { flex-direction: row; justify-content: flex-end; gap: 16px; }
}

.pager { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.pager a, .pager b {
    display: inline-block;
    min-width: 38px;
    text-align: center;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 500;
    background: #fff;
}
.pager a:hover { border-color: var(--brand); }
.pager b { background: var(--brand); border-color: var(--brand); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 32px 0; }
