:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --text: #172126;
    --muted: #66747c;
    --line: #e2e8ec;
    --primary: #8a5a6c;
    --primary-2: #6f4353;
    --primary-soft: #f3e9ed;
    --success: #23856d;
    --warning: #b8781d;
    --danger: #b84d55;
    --sidebar: #182126;
    --sidebar-2: #222e34;
    --radius: 16px;
    --shadow: 0 18px 50px rgba(26, 37, 42, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(420px, 1.1fr) minmax(380px, .9fr);
    background: var(--surface);
}
.login-visual {
    padding: clamp(42px, 7vw, 110px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        radial-gradient(circle at 15% 20%, rgba(179, 118, 142, .24), transparent 32%),
        linear-gradient(140deg, #151e23, #26343a 58%, #303c42);
    color: white;
    position: relative;
    overflow: hidden;
}
.login-visual::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 50%;
    right: -160px;
    bottom: -130px;
    box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018);
}
.login-brand-mark, .brand-mark {
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: -.04em;
    background: linear-gradient(135deg, #d4a3b5, #8a5a6c);
    color: white;
}
.login-brand-mark { width: 62px; height: 62px; border-radius: 20px; font-size: 22px; }
.login-visual h1 { margin: 12px 0 16px; font-size: clamp(42px, 5vw, 72px); line-height: .98; letter-spacing: -.05em; max-width: 650px; }
.login-visual p { max-width: 620px; color: rgba(255,255,255,.72); font-size: 18px; line-height: 1.7; }
.login-security { color: rgba(255,255,255,.48); font-size: 13px; }
.login-panel { display: grid; place-items: center; padding: 34px; }
.login-card { width: min(430px, 100%); }
.login-card h2 { margin: 10px 0 30px; font-size: 34px; letter-spacing: -.03em; }
.mobile-brand { display: none; font-weight: 800; font-size: 22px; margin-bottom: 28px; }

.eyebrow { display: block; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; color: #39464c; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    padding: 12px 13px;
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(138,90,108,.12); }
.login-card label { margin-bottom: 18px; }
.form-help { margin: 16px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.btn {
    border: 0;
    border-radius: 11px;
    padding: 11px 16px;
    font-weight: 800;
    transition: transform .15s, background .2s, opacity .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-2); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: #fff0f1; color: var(--danger); }
.btn-block { width: 100%; }
.btn-small { padding: 8px 11px; font-size: 12px; }
.btn-icon { border: 0; background: transparent; color: inherit; font-size: 21px; padding: 8px; border-radius: 10px; }

.app { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar);
    color: white;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 5px 10px 28px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; color: rgba(255,255,255,.45); font-size: 11px; margin-top: 2px; }
.nav { display: grid; gap: 5px; }
.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0;
    border-radius: 11px;
    padding: 11px 12px;
    background: transparent;
    color: rgba(255,255,255,.64);
    text-align: left;
    font-weight: 700;
    font-size: 13px;
}
.nav-item span { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover, .nav-item.active { color: white; background: var(--sidebar-2); }
.nav-item.active { box-shadow: inset 3px 0 var(--primary); }
.sidebar-footer { margin-top: auto; padding: 15px 8px 0; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-mini { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; font-weight: 800; }
.user-mini strong, .user-mini span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 128px; }
.user-mini strong { font-size: 12px; }
.user-mini span { color: rgba(255,255,255,.42); font-size: 10px; margin-top: 2px; }

.main { min-width: 0; }
.topbar {
    min-height: 91px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px clamp(20px, 3vw, 42px);
    background: rgba(244,246,248,.9);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(226,232,236,.75);
}
.topbar h2 { margin: 4px 0 0; font-size: 25px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.today { color: var(--muted); font-size: 12px; }
.menu-btn { display: none; border: 0; background: transparent; font-size: 22px; }
.view-container { padding: 28px clamp(20px, 3vw, 42px) 50px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.stat-card, .panel {
    background: var(--surface);
    border: 1px solid rgba(226,232,236,.8);
    border-radius: var(--radius);
    box-shadow: 0 9px 30px rgba(26,37,42,.045);
}
.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 80px; height: 80px; border-radius: 50%; background: var(--primary-soft); right: -25px; top: -30px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-value { display: block; margin-top: 10px; font-size: 29px; font-weight: 850; letter-spacing: -.04em; }
.stat-note { margin-top: 7px; color: var(--muted); font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 15px; margin-top: 15px; }
.panel { padding: 20px; min-width: 0; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.panel-header h3 { margin: 0; font-size: 16px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; }
.toolbar .search { max-width: 330px; }
.toolbar-spacer { flex: 1; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.badge-success { background: #e7f6f1; color: var(--success); }
.badge-warning { background: #fff4df; color: var(--warning); }
.badge-danger { background: #ffebed; color: var(--danger); }
.badge-neutral { background: #eef2f4; color: #526169; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty strong { color: var(--text); display: block; margin-bottom: 5px; }

.chart { height: 235px; display: flex; align-items: end; gap: 9px; padding-top: 25px; }
.chart-column { flex: 1; min-width: 0; display: grid; gap: 7px; justify-items: center; }
.chart-bar { width: min(38px, 72%); min-height: 3px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #b98094, var(--primary)); transition: height .35s ease; }
.chart-label { color: var(--muted); font-size: 9px; }
.chart-value { font-size: 9px; font-weight: 800; white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 5px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(9,14,17,.62); backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(760px, 100%); max-height: 92vh; overflow: auto; background: white; border-radius: 18px; box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 20px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: white; z-index: 2; }
.modal-header h3 { margin: 4px 0 0; }
.modal-close { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 10px; font-size: 20px; }
.modal-body { padding: 22px; }

.pos-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(330px, .6fr); gap: 15px; align-items: start; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.item-card { border: 1px solid var(--line); background: white; border-radius: 13px; padding: 14px; text-align: left; transition: border-color .2s, transform .15s; }
.item-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.item-card strong { display: block; font-size: 13px; line-height: 1.35; min-height: 35px; }
.item-card span { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
.item-card b { display: block; margin-top: 12px; color: var(--primary-2); }
.cart-panel { position: sticky; top: 118px; }
.cart-list { display: grid; gap: 8px; max-height: 340px; overflow: auto; }
.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 26px; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 11px; }
.cart-row strong { display: block; font-size: 12px; }
.cart-row span { color: var(--muted); font-size: 10px; }
.cart-row input { padding: 8px; }
.cart-remove { border: 0; background: #fff0f1; color: var(--danger); width: 26px; height: 26px; border-radius: 8px; }
.cart-totals { margin-top: 15px; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.total-row { display: flex; justify-content: space-between; font-size: 12px; }
.total-row.grand { font-size: 18px; font-weight: 850; color: var(--primary-2); }

.history-layout { display: grid; grid-template-columns: minmax(320px, .7fr) minmax(0, 1.3fr); gap: 15px; }
.timeline { display: grid; gap: 10px; }
.timeline-card { position: relative; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 12px 12px 0; padding: 14px 118px 14px 14px; }
.timeline-card-head { display: block; margin-bottom: 7px; }
.timeline-card h4 { margin: 0; font-size: 13px; }
.timeline-delete-btn { position: absolute; top: 12px; right: 12px; z-index: 5; border: 1px solid #8f455d; background: #9a5870; color: #fff; border-radius: 9px; padding: 8px 12px; font: inherit; font-size: 11px; font-weight: 800; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(105, 48, 67, .22); transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.timeline-delete-btn:hover { background: #7f4055; border-color: #74374c; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(105, 48, 67, .28); }
.timeline-delete-btn:disabled { opacity: .55; cursor: wait; transform: none; box-shadow: none; }
.timeline-meta { color: var(--muted); font-size: 10px; margin-bottom: 10px; }
.timeline-card p { margin: 5px 0; font-size: 12px; line-height: 1.55; }

@media (max-width: 640px) {
    .timeline-card { padding-right: 14px; padding-top: 50px; }
    .timeline-delete-btn { top: 10px; right: 10px; }
}

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 200; min-width: 260px; max-width: 420px; padding: 13px 15px; border-radius: 12px; background: #1c282e; color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f3640; }
.toast.success { background: #176b59; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .login-screen { grid-template-columns: 1fr; }
    .login-visual { display: none; }
    .mobile-brand { display: block; }
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .25s; width: 260px; box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: block; }
    .topbar { justify-content: flex-start; }
    .topbar-actions { margin-left: auto; }
    .today { display: none; }
    .dashboard-grid, .pos-layout, .history-layout { grid-template-columns: 1fr; }
    .cart-panel { position: static; }
}

@media (max-width: 620px) {
    .login-panel { padding: 24px; }
    .topbar { padding: 16px; }
    .topbar h2 { font-size: 20px; }
    .topbar-actions .btn { padding: 9px 11px; font-size: 11px; }
    .view-container { padding: 18px 14px 35px; }
    .stats-grid { grid-template-columns: 1fr; }
    .panel { padding: 15px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full, .form-actions { grid-column: auto; }
    .catalog-grid { grid-template-columns: 1fr 1fr; }
    .modal { padding: 0; align-items: end; }
    .modal-card { border-radius: 18px 18px 0 0; max-height: 94vh; }
}

@media (max-width: 420px) {
    .catalog-grid { grid-template-columns: 1fr; }
}
