:root {
    --green: #659b24;
    --green-dark: #4c7b16;
    --green-soft: #edf6df;
    --ink: #172015;
    --muted: #697265;
    --line: #dce4d8;
    --panel: #fff;
    --background: #f4f7f1;
    --danger: #b63838;
    --shadow: 0 16px 38px rgba(37, 55, 26, .07);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 80% 0, #eaf3df 0, transparent 28rem), var(--background); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; font-size: 15px; }
a { color: var(--green-dark); text-decoration: none; }
a:hover { color: var(--green); }
button, input, select { font: inherit; }

.site-header { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.header-inner { width: min(1180px, calc(100% - 40px)); min-height: 68px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.brand { color: var(--ink); font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.brand span { color: var(--green); }
.main-nav, .guest-nav { display: flex; align-items: center; gap: 22px; font-size: 13px; font-weight: 650; }
.main-nav a, .guest-nav a { color: var(--ink); padding: 26px 0 23px; border-bottom: 3px solid transparent; }
.main-nav a.active { color: var(--green-dark); border-color: var(--green); }
.main-nav form { margin: 0; }
.nav-logout, .text-button { border: 0; padding: 0; color: var(--green-dark); background: transparent; cursor: pointer; font-weight: 650; }
.nav-logout:hover, .text-button:hover { color: var(--green); }
.text-button.danger { color: var(--danger); }
.nav-toggle { display: none; border: 1px solid var(--line); background: white; border-radius: 10px; padding: 8px 12px; }

.cabinet-container { width: min(1180px, calc(100% - 40px)); margin: 42px auto 70px; }
.hero-panel { min-height: 210px; display: flex; align-items: end; justify-content: space-between; gap: 30px; padding: 38px; border: 1px solid #d5e2cd; border-radius: 24px; background: linear-gradient(135deg, #fff 40%, #edf6df); box-shadow: var(--shadow); }
.hero-panel h1, .page-heading h1 { margin: 5px 0 10px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.045em; line-height: 1.05; }
.hero-panel p, .page-heading p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 !important; color: var(--green-dark) !important; font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.stat-card { min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 30px; letter-spacing: -.04em; }
.dashboard-grid, .order-detail-grid, .profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dashboard-grid { grid-template-columns: 2fr 1fr; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); padding: 24px; }
.panel-span-2 { grid-column: 1 / -1; }
.panel-heading { min-height: 38px; display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 19px; }
.panel-heading h2 { margin: 2px 0 0; font-size: 21px; letter-spacing: -.025em; }
.panel-heading > a { font-size: 13px; font-weight: 650; }

.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 0 0 25px; }
.page-heading h1 { font-size: clamp(32px, 4vw, 44px); }
.order-heading { align-items: center; }
.count-chip, .method-chip, .default-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 11px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 750; }
.default-chip { background: var(--ink); color: white; }
.back-link { display: inline-block; margin-bottom: 24px; font-weight: 650; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 11px; padding: 10px 18px; font-weight: 750; cursor: pointer; transition: .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { color: #fff; background: var(--green-dark); }
.button-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button-secondary:hover { color: var(--green-dark); border-color: #b9cbae; }
.button-wide { width: 100%; }
.button-small { min-height: 36px; padding: 7px 12px; font-size: 12px; }

.order-list { border-top: 1px solid var(--line); }
.order-row { display: grid; grid-template-columns: 1.5fr 1fr .8fr 28px; align-items: center; gap: 14px; color: var(--ink); padding: 17px 4px; border-bottom: 1px solid var(--line); }
.order-row span:first-child { display: flex; flex-direction: column; gap: 5px; }
.order-row small, .orders-table small, .item-row small, .shipment-card small { display: block; color: var(--muted); font-size: 11px; font-style: normal; margin-top: 5px; }
.order-row i { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); font-style: normal; }
.address-summary p { color: var(--muted); line-height: 1.55; }
.address-summary > strong { display: block; margin-top: 16px; font-size: 18px; }
.empty-state { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 19px; }

.status-badge { display: inline-flex; width: fit-content; align-items: center; padding: 7px 11px; border-radius: 999px; background: #f0f1ef; color: #545953; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-badge.large { padding: 10px 15px; font-size: 13px; }
.status-new { background: #edf7d9; color: #477b0d; }
.status-confirmed, .status-paid { background: #def2ef; color: #14685e; }
.status-processing { background: #fff0cf; color: #8b5a00; }
.status-shipped { background: #e2edff; color: #315f9e; }
.status-awaiting_pickup { background: #eee7ff; color: #5a3e9d; }
.status-completed { background: #e1f3e3; color: #277332; }
.status-cancelled { background: #fde5e5; color: #a03232; }

.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.orders-table { width: 100%; border-collapse: collapse; text-align: left; }
.orders-table th { padding: 15px 17px; color: var(--muted); background: #fafcf9; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.orders-table td { padding: 18px 17px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.orders-table tr:last-child td { border-bottom: 0; }
.order-number { color: var(--ink); font-weight: 800; font-size: 12px; }
.round-link { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); font-weight: 800; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 17px 22px; border-top: 1px solid var(--line); font-size: 13px; }
.pagination a:last-child { justify-self: end; }

.items-list { border-top: 1px solid var(--line); }
.item-row { display: grid; grid-template-columns: 1fr auto 120px; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.item-row > strong { text-align: right; }
.total-row { display: flex; justify-content: space-between; padding-top: 20px; font-size: 17px; }
.total-row strong { font-size: 22px; }
.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 100px 1fr; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-list > div:last-child { border: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; line-height: 1.5; font-weight: 650; }
.shipment-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.shipment-card { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfa; }
.shipment-card div { display: flex; flex-direction: column; gap: 5px; }
.shipment-card span { color: var(--muted); font-size: 11px; }
.shipment-card .button { grid-column: 1 / -1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: 13px; padding-bottom: 18px; position: relative; }
.timeline li > span { width: 11px; height: 11px; margin-top: 4px; border: 3px solid #dcebc9; border-radius: 50%; background: var(--green); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 17px; bottom: 2px; width: 1px; background: var(--line); }
.timeline div { display: flex; flex-direction: column; gap: 4px; }
.timeline small { color: var(--muted); }

.addresses-layout.with-form { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 18px; }
.address-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.with-form .address-grid { grid-template-columns: 1fr; }
.address-card { position: relative; }
.address-card.is-default { border-color: #bfd5ad; }
.card-top { display: flex; justify-content: space-between; gap: 10px; }
.address-card h2 { margin: 18px 0 10px; font-size: 20px; }
.address-card p { color: var(--muted); line-height: 1.55; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.card-actions form { margin: 0; }
.address-form-panel { position: sticky; top: 90px; }

.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.two { margin-bottom: 16px; }
.field-full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
label small { color: var(--muted); font-size: 11px; font-weight: 400; }
input, select { width: 100%; min-height: 46px; border: 1px solid #ced8c9; border-radius: 11px; padding: 10px 12px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(101,155,36,.13); }
input:disabled { background: #f3f5f1; color: var(--muted); }
.check-label { flex-direction: row; align-items: center; gap: 9px; }
.check-label input { width: 18px; min-height: 18px; }
[hidden] { display: none !important; }

.auth-page { background: radial-gradient(circle at 20% 10%, #e7f1da, transparent 28rem), #f5f7f3; }
.auth-shell { width: min(760px, calc(100% - 32px)); min-height: calc(100vh - 136px); margin: 0 auto; display: grid; place-items: center; padding: 45px 0; }
.auth-card { width: min(600px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 25px 60px rgba(33,50,23,.1); }
.auth-card-wide { width: 100%; }
.auth-card h1 { margin: 7px 0 10px; font-size: 34px; letter-spacing: -.04em; }
.lead { margin: 0 0 25px; color: var(--muted); line-height: 1.55; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 21px; font-size: 13px; }
.inline-action { margin-top: 18px; text-align: center; }
.code-input { font-size: 26px; font-weight: 800; letter-spacing: .35em; text-align: center; }
.form-error, .flash { border: 1px solid #edc0c0; border-radius: 11px; padding: 12px 14px; color: #8d2727; background: #fff0f0; line-height: 1.45; }
.page-error { margin: -10px 0 20px; }
.flash-stack { position: fixed; z-index: 50; top: 82px; right: 20px; width: min(390px, calc(100% - 40px)); display: flex; flex-direction: column; gap: 8px; }
.flash-success { border-color: #c9dfb6; color: #366a15; background: #f1f9e9; box-shadow: var(--shadow); }
.flash-info { border-color: #c9d9e8; color: #315c78; background: #eff7fd; }
.site-footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; min-height: 68px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid, .profile-grid, .addresses-layout.with-form { grid-template-columns: 1fr; }
    .address-form-panel { position: static; }
    .shipment-grid { grid-template-columns: 1fr; }
    .nav-toggle { display: block; }
    .main-nav { display: none; position: absolute; left: 20px; right: 20px; top: 61px; flex-direction: column; align-items: stretch; gap: 0; padding: 10px 18px 17px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
    .main-nav.is-open { display: flex; }
    .main-nav a { padding: 12px 0; border: 0; }
    .main-nav form { padding: 12px 0 2px; }
}

@media (max-width: 680px) {
    .header-inner, .cabinet-container, .site-footer { width: min(100% - 24px, 1180px); }
    .guest-nav { gap: 12px; }
    .cabinet-container { margin-top: 24px; }
    .hero-panel { align-items: start; flex-direction: column; padding: 26px; }
    .hero-panel .button { width: 100%; }
    .stats-grid, .address-grid, .form-grid, .form-grid.two, .order-detail-grid { grid-template-columns: 1fr; }
    .page-heading { align-items: start; flex-direction: column; }
    .page-heading .button { width: 100%; }
    .panel { padding: 19px; }
    .order-row { grid-template-columns: 1fr auto; }
    .order-row > strong { grid-column: 1; }
    .order-row > i { grid-column: 2; grid-row: 1 / span 2; }
    .orders-table thead { display: none; }
    .orders-table, .orders-table tbody, .orders-table tr, .orders-table td { display: block; width: 100%; }
    .orders-table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
    .orders-table td { display: flex; justify-content: space-between; gap: 15px; padding: 7px 0; border: 0; text-align: right; }
    .orders-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; text-align: left; }
    .orders-table td:last-child { display: none; }
    .item-row { grid-template-columns: 1fr auto; }
    .item-row > strong { grid-column: 1 / -1; text-align: left; }
    .shipment-card { grid-template-columns: 1fr; }
    .shipment-card .button { grid-column: 1; }
    .auth-card { padding: 26px 20px; }
    .auth-card-wide { width: 100%; }
    .auth-links { flex-direction: column; }
}
