/* --- Variables & Reset --- */
:root {
    --bg-dark: #0b0b1a;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(233, 69, 96, 0.10), transparent 60%),
               radial-gradient(900px 500px at 110% 10%, rgba(99, 102, 241, 0.10), transparent 60%);
    --card-bg: rgba(22, 22, 44, 0.78);
    --card-solid: #16162c;
    --card-border: rgba(255, 255, 255, 0.07);
    --card-border-strong: rgba(255, 255, 255, 0.12);
    --primary: #f0476a;
    --primary-hover: #dc355a;
    --primary-soft: rgba(240, 71, 106, 0.12);
    --secondary: #24346b;
    --secondary-hover: #2e4386;
    --text-main: #eef0f7;
    --text-muted: #9a9cb8;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #38bdf8;
    --violet: #a78bfa;
    --font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --radius: 14px;
    --transition: all 0.25s cubic-bezier(.4, 0, .2, 1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-grad), var(--bg-dark);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, h4 { font-weight: 700; margin-bottom: 0.5rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; }
a { text-decoration: none; color: inherit; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--primary); }
.small { font-size: 0.85rem; }
.link-muted { color: var(--text-muted); font-size: 0.9rem; transition: var(--transition); }
.link-muted:hover { color: var(--primary); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Layout --- */
.hidden { display: none !important; }
.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }

/* --- Forms & Buttons --- */
.form-group {
    position: relative;
    margin-bottom: 1.25rem;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border-strong);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}
.form-group textarea { min-height: 90px; resize: vertical; }
.form-group select option, .filter-group select option { background: var(--card-solid); color: var(--text-main); }

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.form-group label {
    position: absolute;
    left: 1rem;
    top: 0.95rem;
    color: var(--text-muted);
    transition: var(--transition);
    pointer-events: none;
    font-size: 0.95rem;
}

.form-group input:focus ~ label,
.form-group input:not(:placeholder-shown) ~ label,
.form-group textarea:focus ~ label,
.form-group textarea:not(:placeholder-shown) ~ label,
.form-group select ~ label,
.form-group input[type="date"] ~ label,
.form-group label.static {
    top: -0.55rem;
    left: 0.75rem;
    font-size: 0.75rem;
    background: var(--card-solid);
    padding: 0 0.4rem;
    border-radius: 4px;
    color: var(--primary);
}
input[type="date"], input[type="month"] { color-scheme: dark; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-error { color: var(--danger); font-size: 0.9rem; margin: -0.5rem 0 1rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.25rem; color: var(--text-muted); cursor: pointer; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.3rem;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-lg { padding: 0.95rem 1.8rem; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; border-radius: 8px; }

.btn-primary { background: linear-gradient(135deg, #f0476a, #e0457f); color: #fff; box-shadow: 0 6px 18px rgba(240, 71, 106, 0.28); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #f35b7b, #e65590); box-shadow: 0 8px 22px rgba(240, 71, 106, 0.38); }

.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--secondary-hover); }

.btn-ghost { background: rgba(255, 255, 255, 0.04); border-color: var(--card-border-strong); color: var(--text-main); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); }

.btn-success { background: rgba(52, 211, 153, 0.15); border-color: rgba(52, 211, 153, 0.4); color: var(--success); }
.btn-success:hover:not(:disabled) { background: rgba(52, 211, 153, 0.25); }

.btn-warning { background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.4); color: var(--warning); }
.btn-warning:hover:not(:disabled) { background: rgba(251, 191, 36, 0.22); }

.btn-outline-danger { background: transparent; border: 1px solid rgba(248, 113, 113, 0.5); color: var(--danger); }
.btn-outline-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-icon { background: transparent; border: none; color: var(--text-main); font-size: 1.35rem; cursor: pointer; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 0.3rem 0.45rem; border-radius: 6px; transition: var(--transition); }
.icon-btn:hover { color: var(--danger); background: rgba(248, 113, 113, 0.1); }

/* --- Login --- */
.login-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    overflow: hidden;
}
.login-glow {
    position: absolute; width: 520px; height: 520px; border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 71, 106, 0.25), transparent 65%);
    filter: blur(20px); animation: float 9s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translate(-80px, -40px); } 50% { transform: translate(80px, 40px); } }
.login-card {
    position: relative;
    background: var(--card-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 2.75rem 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 410px;
    border: 1px solid var(--card-border-strong);
    animation: rise 0.5s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand h1 { font-size: 1.5rem; margin: 1rem 0 0.2rem; }
.brand-icon {
    width: 60px; height: 60px; margin: 0 auto; border-radius: 16px;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: #fff;
    background: linear-gradient(135deg, #f0476a, #8b5cf6);
    box-shadow: 0 10px 25px rgba(240, 71, 106, 0.35);
}
.brand-icon.small { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; margin: 0; box-shadow: none; }

/* --- App Layout --- */
#app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: rgba(16, 16, 34, 0.92);
    backdrop-filter: blur(14px);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}
.sidebar-header {
    padding: 1.4rem 1.5rem;
    display: flex; align-items: center; gap: 0.75rem;
    font-weight: 800; font-size: 1.15rem;
    border-bottom: 1px solid var(--card-border);
}
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: 10px;
    font-weight: 500;
    transition: var(--transition);
}
.sidebar-nav a i { margin-right: 12px; width: 18px; text-align: center; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-main); }
.sidebar-nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav-badge {
    margin-left: auto; background: var(--primary); color: #fff; font-size: 0.7rem; font-weight: 700;
    padding: 0.1rem 0.5rem; border-radius: 999px;
}
.sidebar-footer { padding: 1.25rem; border-top: 1px solid var(--card-border); display: flex; flex-direction: column; gap: 0.75rem; }
.owner-chip { color: var(--text-muted); font-size: 0.88rem; display: flex; align-items: center; gap: 0.5rem; }
.sidebar-overlay { display: none; }

.main-content {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 68px;
    background: rgba(11, 11, 26, 0.75);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title h2 { margin: 0; font-size: 1.25rem; }
.topbar-right { margin-left: auto; }
.today-chip { color: var(--text-muted); font-size: 0.88rem; background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); padding: 0.4rem 0.8rem; border-radius: 999px; }
#mobile-menu-btn { display: none; margin-right: 1rem; }

.content-area { padding: 1.75rem 2rem 3rem; flex: 1; }
.view { animation: fadeIn 0.3s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --- Cards --- */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--card-border);
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}
.card-header { margin-bottom: 1rem; border-bottom: 1px solid var(--card-border); padding-bottom: 0.75rem; }
.card-header h3 { margin: 0; }
.card-header-flex { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-header-flex h3 { margin: 0; }

/* --- Alert banners --- */
.alert-banner {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.85rem 1.1rem; border-radius: 12px; margin-bottom: 1.25rem; font-size: 0.92rem;
    border: 1px solid;
}
.alert-banner a { text-decoration: underline; font-weight: 600; }
.alert-banner.warning { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.35); color: var(--warning); }
.alert-banner.danger { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.35); color: var(--danger); }
.alert-banner.success { background: rgba(52, 211, 153, 0.08); border-color: rgba(52, 211, 153, 0.35); color: var(--success); }

/* --- Dashboard --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: 1.25rem; }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.summary-cards .card { margin-bottom: 0; }
.summary-card { --accent: var(--primary); display: flex; align-items: center; position: relative; overflow: hidden; transition: var(--transition); }
.summary-card::before {
    content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); opacity: 0.85;
}
.summary-card:hover { transform: translateY(-2px); border-color: var(--card-border-strong); }
.summary-card.clickable { cursor: pointer; }
.summary-card .card-icon {
    font-size: 1.35rem;
    color: var(--accent);
    margin-right: 1rem;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    width: 52px; height: 52px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 14px;
}
.summary-card h3 { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.2rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.summary-card p { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary-card small { font-size: 0.8rem; }
.accent-rose { --accent: #f0476a; }
.accent-emerald { --accent: #34d399; }
.accent-sky { --accent: #38bdf8; }
.accent-violet { --accent: #a78bfa; }
.accent-amber { --accent: #fbbf24; }
.accent-slate { --accent: #94a3b8; }
.alert-card { border-color: rgba(248, 113, 113, 0.5); box-shadow: 0 0 18px rgba(248, 113, 113, 0.15); }

.chart-wrap { position: relative; height: 320px; }
.chart-wrap .empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; }

/* --- Tables --- */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.92rem; }
.table th, .table td { padding: 0.85rem 0.9rem; border-bottom: 1px solid var(--card-border); }
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--card-border-strong); border-bottom: none; }
.table-hover tbody tr { transition: background 0.15s ease; }
.table-hover tbody tr:hover { background: rgba(255, 255, 255, 0.035); cursor: pointer; }
.table td.empty { text-align: center; color: var(--text-muted); padding: 2rem; }

/* --- Badges & Status --- */
.badge { display: inline-block; padding: 0.22rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-blue { background: rgba(56, 189, 248, 0.14); color: var(--info); }
.badge-green { background: rgba(52, 211, 153, 0.14); color: var(--success); }
.badge-red { background: rgba(248, 113, 113, 0.14); color: var(--danger); }
.badge-amber { background: rgba(251, 191, 36, 0.14); color: var(--warning); }
.badge-gray { background: rgba(148, 163, 184, 0.14); color: #94a3b8; }

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.warning-icon { animation: pulse 2s infinite; color: var(--warning); margin-right: 5px; display: inline-block; }
.row-warning { background: rgba(248, 113, 113, 0.07) !important; box-shadow: inset 3px 0 0 var(--danger); }

/* --- Filtering --- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filter-group { flex: 1; min-width: 180px; }
.filter-group.compact { flex: 0 1 220px; }
.filter-group label { display: block; margin-bottom: 0.4rem; font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.filter-group input, .filter-group select {
    width: 100%; padding: 0.6rem 0.75rem; border-radius: 9px; background: rgba(255,255,255,0.04);
    border: 1px solid var(--card-border-strong); color: var(--text-main); font-family: inherit; font-size: 0.9rem; outline: none;
    transition: var(--transition);
}
.filter-group input:focus, .filter-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filter-actions { display: flex; gap: 0.6rem; }

/* --- Modals --- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(5, 5, 15, 0.72); backdrop-filter: blur(4px); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    animation: fadeIn 0.2s ease both;
}
.modal {
    background: var(--card-solid); border-radius: 18px; padding: 2rem;
    width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
    border: 1px solid var(--card-border-strong); position: relative; box-shadow: var(--shadow);
    animation: rise 0.25s ease both;
}
.modal.wide { max-width: 760px; }
.modal h3 { padding-right: 2rem; }
.modal-close { position: absolute; top: 1.1rem; right: 1.1rem; cursor: pointer; color: var(--text-muted); font-size: 1.25rem; background: none; border: none; transition: var(--transition); }
.modal-close:hover { color: var(--text-main); }
.modal-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; margin-top: 1.25rem; }
.divider { border: none; border-top: 1px solid var(--card-border); margin: 1.25rem 0; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.6rem 1.5rem; margin-top: 1rem; }
.detail-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--card-border); font-size: 0.92rem; }
.detail-row span:first-child { color: var(--text-muted); }
.detail-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-row.total span:last-child { color: var(--success); font-size: 1.05rem; }
.note-box { background: rgba(255,255,255,0.03); border: 1px solid var(--card-border); border-radius: 10px; padding: 0.75rem 1rem; margin-top: 1rem; font-size: 0.9rem; }

/* --- Staff list --- */
.staff-list { list-style: none; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.5rem; }
.staff-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 0.9rem; border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px solid var(--card-border);
}
.staff-item .info { flex: 1; min-width: 0; }
.staff-item .info strong { display: block; }
.staff-item .info small { color: var(--text-muted); }
.staff-item.inactive { opacity: 0.55; }

/* --- Toast --- */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--card-solid); color: var(--text-main); padding: 0.9rem 1.2rem;
    border-radius: 12px; border: 1px solid var(--card-border-strong); border-left: 4px solid var(--primary);
    box-shadow: var(--shadow); opacity: 0; transform: translateX(110%);
    transition: var(--transition); max-width: 360px; font-size: 0.92rem;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* --- Shops grid --- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.shops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.shop-card { display: flex; flex-direction: column; margin-bottom: 0; transition: var(--transition); }
.shop-card:hover { transform: translateY(-2px); border-color: var(--card-border-strong); }
.shop-card .shop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.shop-meta { list-style: none; margin: 0.75rem 0 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; font-size: 0.88rem; color: var(--text-muted); }
.shop-meta li i { width: 16px; margin-right: 6px; color: var(--primary); }
.shop-meta li strong { color: var(--text-main); }
.shop-actions { margin-top: auto; display: flex; gap: 0.6rem; }
.shop-actions .btn { flex: 1; }
.shop-card.inactive { opacity: 0.6; }

/* --- Profile --- */
.profile-header { display: flex; align-items: center; gap: 1.1rem; }
.profile-header h2 { margin: 0; }
.avatar {
    width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.3rem; color: #fff;
    background: linear-gradient(135deg, #f0476a, #8b5cf6);
}

/* --- Empty / loading --- */
.empty-state { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2rem; margin-bottom: 0.6rem; opacity: 0.6; }
.skeleton { color: transparent !important; background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- Responsive --- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
    .sidebar.open + .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
    .main-content { margin-left: 0; }
    #mobile-menu-btn { display: block; }
    .content-area { padding: 1.25rem 1rem 2.5rem; }
    .topbar { padding: 0 1rem; }
    .today-chip { display: none; }
}
@media (max-width: 600px) {
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-group, .filter-group.compact { width: 100%; flex: 1 1 auto; }
    .form-row { grid-template-columns: 1fr; }
    .login-card { padding: 2rem 1.5rem; }
    .summary-card p { font-size: 1.25rem; }
}
