:root {
    --bg-1: #120707;
    --bg-2: #1a0b0b;
    --bg-3: #241010;

    --surface: rgba(32, 15, 15, 0.78);
    --surface-strong: rgba(22, 10, 10, 0.92);
    --surface-soft: rgba(255, 255, 255, 0.04);

    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);

    --text: #f5eaea;
    --text-soft: #d8b9b9;
    --text-muted: #b48f8f;
    --heading: #ffffff;

    --primary: #b31212;
    --primary-2: #d11717;
    --primary-3: #7f0d0d;

    --accent-soft: #f4d6d6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;

    --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.42);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.18);

    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Tahoma, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(179, 18, 18, 0.28), transparent 28%),
        radial-gradient(circle at top right, rgba(120, 20, 20, 0.18), transparent 24%),
        radial-gradient(circle at bottom left, rgba(209, 23, 23, 0.10), transparent 28%),
        linear-gradient(135deg, var(--bg-1), var(--bg-2) 52%, var(--bg-3));
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(90px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.28;
}

body::before {
    top: -120px;
    left: -100px;
    background: #c41414;
}

body::after {
    bottom: -150px;
    right: -90px;
    background: #6d0d0d;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 34px auto;
    padding: 0 18px 24px;
}

.small {
    max-width: 460px;
}

h1 {
    margin: 0;
    font-size: 42px;
    line-height: 1.05;
    font-weight: 900;
    letter-spacing: -0.03em;
    color: var(--heading);
}

.page-subtitle {
    margin-top: 10px;
    color: var(--text-soft);
    font-size: 15px;
    line-height: 1.5;
}

p {
    margin: 0;
    color: var(--text-soft);
}

a {
    color: inherit;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.topbar > div:first-child {
    padding: 2px 0;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.topbar::after {
    content: "";
    display: block;
    width: 100%;
    height: 1px;
    margin-top: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.12), rgba(179,18,18,0.22), transparent);
}

.card {
    position: relative;
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    margin-bottom: 22px;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.05), transparent 34%, transparent 68%, rgba(179,18,18,0.06));
    pointer-events: none;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin-bottom: 9px;
    color: #f1dede;
    text-transform: uppercase;
}

input,
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 16px;
    background: rgba(255,255,255,0.045);
    color: #fff7f7;
    font-size: 14px;
    outline: none;
    transition: 0.22s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

input::placeholder,
textarea::placeholder {
    color: #ba9999;
}

input:hover,
textarea:hover,
select:hover {
    border-color: rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(209, 23, 23, 0.8);
    background: rgba(255,255,255,0.08);
    box-shadow:
        0 0 0 4px rgba(209, 23, 23, 0.16),
        0 12px 24px rgba(0, 0, 0, 0.22);
}

select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #e6caca 50%),
        linear-gradient(135deg, #e6caca 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 40px;
}

textarea {
    resize: vertical;
    min-height: 118px;
}

button,
.btn,
.btn-secondary {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 16px;
    padding: 13px 20px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: 0.22s ease;
    border: 1px solid transparent;
    overflow: hidden;
    white-space: nowrap;
}

button::before,
.btn::before,
.btn-secondary::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,0.16), transparent 80%);
    transform: translateX(-120%);
    transition: 0.55s ease;
}

button:hover::before,
.btn:hover::before,
.btn-secondary:hover::before {
    transform: translateX(120%);
}

button,
.btn {
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2) 55%, var(--primary-3));
    box-shadow:
        0 14px 34px rgba(179, 18, 18, 0.32),
        inset 0 1px 0 rgba(255,255,255,0.18);
}

button:hover,
.btn:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow:
        0 18px 42px rgba(179, 18, 18, 0.42),
        inset 0 1px 0 rgba(255,255,255,0.22);
}

button:active,
.btn:active,
.btn-secondary:active {
    transform: translateY(0);
}

.btn-secondary {
    color: #f2dede;
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.16);
}

.alert {
    border-radius: 18px;
    padding: 15px 18px;
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid transparent;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.success {
    background: rgba(34, 197, 94, 0.12);
    color: #b6f3c9;
    border-color: rgba(34, 197, 94, 0.28);
}

.error {
    background: rgba(239, 68, 68, 0.12);
    color: #ffc6c6;
    border-color: rgba(239, 68, 68, 0.28);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(250px, 1fr));
    gap: 20px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.create-order-form {
    max-width: 980px;
    margin-inline: auto;
}

.field-hint {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
}

.form-actions .btn-secondary {
    padding: 13px 18px;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
}

.orders-table {
    width: 100%;
    min-width: 1220px;
    border-collapse: separate;
    border-spacing: 0;
}

.orders-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
    color: #f3d8d8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 900;
    padding: 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: left;
    white-space: nowrap;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.orders-table thead th:first-child {
    border-top-left-radius: 18px;
}

.orders-table thead th:last-child {
    border-top-right-radius: 18px;
}

.orders-table tbody td {
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    vertical-align: top;
    font-size: 14px;
    line-height: 1.55;
    background: transparent;
    color: var(--text);
    transition: 0.18s ease;
}

.orders-table tbody tr:hover td {
    background: rgba(255,255,255,0.025);
}

.cell-id {
    font-weight: 900;
    color: #ff8f8f;
    white-space: nowrap;
}

.main-value {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
}

.sub-value {
    margin-top: 6px;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.5;
}

.address-block,
.articles-block,
.notes-block {
    max-width: 260px;
    color: #fff1f1;
    line-height: 1.55;
    word-break: break-word;
}

.articles-block {
    white-space: pre-line;
}

.notes-block {
    margin-top: 10px;
}

.date-block {
    white-space: nowrap;
    font-weight: 800;
    color: #ffffff;
}

.date-block span {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
    border: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.95;
    box-shadow: 0 0 10px currentColor;
}

.badge-new {
    background: rgba(209, 23, 23, 0.12);
    color: #ff8e8e;
    border-color: rgba(209, 23, 23, 0.22);
}

.badge-pack {
    background: rgba(245, 158, 11, 0.14);
    color: #ffd27e;
    border-color: rgba(245, 158, 11, 0.2);
}

.badge-send {
    background: rgba(34, 197, 94, 0.14);
    color: #8cf1b2;
    border-color: rgba(34, 197, 94, 0.22);
}

.badge-doc-pending {
    background: rgba(255, 199, 82, 0.14);
    color: #ffd978;
    border-color: rgba(255, 199, 82, 0.2);
}

.badge-doc-done {
    background: rgba(34, 197, 94, 0.14);
    color: #8cf1b2;
    border-color: rgba(34, 197, 94, 0.22);
}

.action-cell {
    min-width: 240px;
}

.status-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 190px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
}

.status-form select,
.status-form button,
.status-form input {
    width: 100%;
}

.mini-label {
    font-size: 11px;
    font-weight: 900;
    color: #d2a9a9;
    margin-bottom: -2px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.empty-state {
    text-align: center;
    padding: 42px 20px !important;
    color: var(--text-soft);
    font-weight: 700;
}

.login-box {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 470px;
    background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
    border-radius: 28px;
    padding: 34px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.login-card h1 {
    margin-bottom: 10px;
}

.login-card p {
    margin-bottom: 24px;
    color: var(--text-soft);
}

.login-card button {
    width: 100%;
    margin-top: 14px;
}

.tracking-box {
    margin-top: 10px;
    padding: 11px 13px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    color: #f1dede;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}

.logo-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.logo-bar img {
    height: 42px;
    width: auto;
    display: block;
    filter: drop-shadow(0 8px 18px rgba(179, 18, 18, 0.28));
}

@media (max-width: 1100px) {
    .orders-table {
        min-width: 1080px;
    }
}

@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions a,
    .topbar-actions button {
        flex: 1;
    }

    h1 {
        font-size: 34px;
    }
}

@media (max-width: 600px) {
    .container {
        margin: 22px auto;
        padding: 0 12px 18px;
    }

    .card,
    .login-card {
        padding: 18px;
        border-radius: 20px;
    }

    h1 {
        font-size: 28px;
    }

    .btn,
    .btn-secondary,
    button {
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .logo-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}
.salesbook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 24px;
    margin-top: 8px;
}

.salesbook-card {
    position: relative;
    padding: 24px;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: hidden;
}

.salesbook-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(255,255,255,0.05), transparent 30%),
        linear-gradient(135deg, rgba(179,18,18,0.07), transparent 55%);
    pointer-events: none;
}

.salesbook-card-top {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.salesbook-client-name {
    font-size: 28px;
    font-weight: 900;
    line-height: 1.05;
    color: #ffffff;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.salesbook-entry-id {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(179,18,18,0.14);
    border: 1px solid rgba(179,18,18,0.24);
    color: #ffabab;
    font-size: 12px;
    font-weight: 900;
}

.salesbook-block {
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
}

.salesbook-block-label {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #d8a9a9;
    margin-bottom: 8px;
}

.salesbook-block-content {
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    color: #fff3f3;
    line-height: 1.65;
    font-size: 15px;
    white-space: pre-line;
    word-break: break-word;
    min-height: 78px;
}

.salesbook-footer {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.salesbook-meta-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #f0dede;
    font-size: 14px;
}

.salesbook-meta-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 900;
    color: #c59898;
}

.salesbook-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.salesbook-actions .btn-secondary {
    min-width: 110px;
}

.btn-danger-soft {
    background: rgba(239, 68, 68, 0.10);
    color: #ffc7c7;
    border-color: rgba(239, 68, 68, 0.18);
}

.btn-danger-soft:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.28);
}

.empty-salesbook {
    text-align: center;
    padding: 46px 26px;
}

@media (max-width: 700px) {
    .salesbook-grid {
        grid-template-columns: 1fr;
    }

    .salesbook-footer {
        grid-template-columns: 1fr;
    }

    .salesbook-client-name {
        font-size: 24px;
    }

    .salesbook-actions {
        flex-direction: column;
    }

    .salesbook-actions .btn-secondary {
        width: 100%;
    }
}
.salesbook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(390px, 1fr));
    gap: 24px;
    margin-top: 8px;
}

.visit-card,
.visit-detail-card {
    position: relative;
    padding: 24px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: hidden;
}

.visit-card::before,
.visit-detail-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(255,255,255,0.05), transparent 30%),
        linear-gradient(135deg, rgba(179,18,18,0.07), transparent 55%);
    pointer-events: none;
}

.visit-card-top,
.visit-detail-header {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.visit-client-name {
    font-size: 28px;
    font-weight: 900;
    line-height: 1.05;
    color: #ffffff;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.visit-chip-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.visit-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(179,18,18,0.14);
    border: 1px solid rgba(179,18,18,0.24);
    color: #ffabab;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.visit-summary-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin: 20px 0;
}

.visit-mini-box {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
}

.visit-mini-label {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #d0a0a0;
    margin-bottom: 8px;
}

.visit-mini-value {
    color: #fff4f4;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 700;
}

.visit-preview-block,
.detail-section {
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
}

.visit-preview-text,
.salesbook-block-content {
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    color: #fff3f3;
    line-height: 1.65;
    font-size: 15px;
    white-space: pre-line;
    word-break: break-word;
}

.salesbook-block-label {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #d8a9a9;
    margin-bottom: 8px;
}

.visit-footer {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.visit-footer-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #f0dede;
    font-size: 14px;
}

.salesbook-meta-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 900;
    color: #c59898;
}

.salesbook-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.salesbook-actions .btn-secondary {
    min-width: 110px;
}

.btn-danger-soft {
    background: rgba(239, 68, 68, 0.10);
    color: #ffc7c7;
    border-color: rgba(239, 68, 68, 0.18);
}

.btn-danger-soft:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.28);
}

.empty-salesbook {
    text-align: center;
    padding: 46px 26px;
}

@media (max-width: 900px) {
    .salesbook-grid {
        grid-template-columns: 1fr;
    }

    .visit-summary-grid {
        grid-template-columns: 1fr;
    }

    .visit-footer {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .visit-client-name {
        font-size: 24px;
    }

    .salesbook-actions {
        flex-direction: column;
    }

    .salesbook-actions .btn-secondary {
        width: 100%;
    }
}