@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
    --bg: radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.08), transparent 25%), radial-gradient(circle at 80% 10%, rgba(59, 130, 246, 0.12), transparent 20%), #0a111a;
    --surface: #0f1722;
    --surface-2: #121d2a;
    --surface-3: #0d1620;
    --text: #f5f8ff;
    --muted: #9db3c9;
    --accent: #22c55e;
    --accent-2: #0ea5e9;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 14px 50px rgba(0, 0, 0, 0.35);
    --glass: rgba(255, 255, 255, 0.04);
}

:root.light {
    --bg: radial-gradient(circle at 20% 20%, rgba(34, 197, 94, 0.14), transparent 25%), radial-gradient(circle at 80% 0%, rgba(14, 165, 233, 0.12), transparent 18%), #f6f9fd;
    --surface: #ffffff;
    --surface-2: #f2f6fb;
    --surface-3: #e9eef9;
    --text: #0f172a;
    --muted: #6b7285;
    --accent: #10b981;
    --accent-2: #0ea5e9;
    --border: #e4e8f3;
    --shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
    --glass: rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 100vh;
    box-shadow: var(--shadow);
    z-index: 20;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    overflow-y: auto;
}

.logo {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.4px;
    margin-bottom: 18px;
    color: var(--accent);
}

.sidebar nav a {
    display: block;
    padding: 12px 14px;
    margin-bottom: 8px;
    color: var(--muted);
    text-decoration: none;
    border-radius: 12px;
    background: var(--glass);
    border: 1px solid transparent;
    transition: all 0.18s ease;
}

.sidebar nav a:hover {
    color: var(--text);
    border-color: var(--border);
    transform: translateX(3px);
}

.sidebar nav a.active {
    color: var(--text);
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.theme-toggle, .menu-toggle {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.user-box {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.user-box .logout {
    display: inline-block;
    margin-top: 6px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.user-box .logout:hover { text-decoration: underline; }

.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 15;
    backdrop-filter: blur(4px);
}

.content {
    padding: 28px 32px 48px;
    background: var(--bg);
    min-height: 100vh;
    width: 100%;
}

.content-inner {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ghost {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
}

.topbar h1 { margin: 0 0 6px; font-size: 28px; }
.topbar p { margin: 0; color: var(--muted); }

.menu-toggle {
    display: none;
    background: var(--surface-2);
}

.sync-box {
    text-align: right;
    background: var(--surface-2);
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.sync-box button, .save {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0f18;
    border: none;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.sync-box small { display: block; color: var(--muted); margin-top: 6px; }

.section { margin-top: 22px; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}

.card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255,255,255,0.04), transparent 40%);
    pointer-events: none;
}

.card.accent { border-color: var(--accent); box-shadow: 0 10px 30px rgba(88, 224, 166, 0.15); }
.card .label { color: var(--muted); font-size: 12px; letter-spacing: 0.3px; }
.card .value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.cards.compact .card { padding: 10px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header { font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-header.flex { flex-wrap: wrap; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 18px;
    cursor: pointer;
    font-weight: 600;
}
.chip.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0f18; border-color: transparent; }
.chip.danger { background: #ef4444; color: #fff; border-color: #ef4444; }

.badge { padding: 6px 10px; border-radius: 12px; font-weight: 700; }
.badge.positive { background: rgba(16, 185, 129, 0.14); color: #10b981; }
.badge.negative { background: rgba(239, 68, 68, 0.14); color: #ef4444; }

.dual-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dual-list ul { list-style: none; padding: 0; margin: 0; }
.dual-list li { padding: 8px 0; border-bottom: 1px solid var(--border); color: var(--muted); }
.dual-list strong { color: var(--text); }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }
.sub-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; word-break: break-word; }
th { color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
.table-scroll { overflow-x: auto; }

input[type="number"],
input[type="text"],
input[type="date"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
}

textarea { resize: vertical; }
.cost-inline { display: flex; gap: 8px; align-items: center; }
.cost-inline input { flex: 1; }

button.save {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0f18;
    border: none;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.form-field label { display: block; margin-bottom: 4px; font-weight: 600; }
.form-field small { display: block; margin-top: 4px; }
.form-actions { display: flex; align-items: center; gap: 10px; grid-column: 1 / -1; }

.daily-cards { display: flex; flex-direction: column; gap: 12px; }
.daily-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.daily-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.daily-card-header .net { font-size: 18px; font-weight: 700; }
.product-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.product-chip { background: var(--surface-2); border: 1px solid var(--border); padding: 8px 10px; border-radius: 12px; }
.product-chip.alt { background: rgba(37, 99, 235, 0.12); border-color: rgba(37, 99, 235, 0.4); }
.dual-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 8px; }
.product-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.product-box.alt { background: rgba(37, 99, 235, 0.06); }

.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); color: var(--text); }
.auth-card h1 { margin-top: 0; margin-bottom: 6px; }
.alert { padding: 10px 12px; border-radius: 12px; background: rgba(239, 68, 68, 0.16); color: #ef4444; margin-bottom: 12px; }
.alert.success { background: rgba(34, 197, 94, 0.16); color: #22c55e; }

.chart { background: var(--surface); border-radius: 16px; border: 1px solid var(--border); padding: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mobile-cards { display: none; gap: 12px; }
.mobile-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.mobile-card .row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.mobile-card .label { color: var(--muted); font-size: 12px; }
.mobile-card .value { font-weight: 700; }
.badge.status { padding: 4px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; display: inline-block; }
.badge.status.ok { background: rgba(34,197,94,0.16); color: #22c55e; }
.badge.status.warn { background: rgba(234,179,8,0.18); color: #eab308; }
.badge.status.bad { background: rgba(239,68,68,0.18); color: #ef4444; }

.fab { position: fixed; right: 18px; bottom: 22px; z-index: 30; }
.fab button { border: none; border-radius: 999px; padding: 12px 16px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0f18; box-shadow: 0 12px 30px rgba(0,0,0,0.25); cursor: pointer; font-weight: 700; }

.mobile-nav { display: none; }

@media (max-width: 1024px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0;
        width: 80%;
        max-width: 280px;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .backdrop { display: none; }
    .backdrop.show { display: block; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 16px 14px 28px; margin-left: 0; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    th, td { font-size: 13px; }
    .panel { padding: 14px; }
    .table-scroll.mobile-hidden { display: none; }
    .mobile-cards { display: grid; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface-2); border-top: 1px solid var(--border); z-index: 28; }
    .mobile-nav a { text-align: center; padding: 10px 6px; color: var(--muted); text-decoration: none; font-size: 13px; }
    .mobile-nav a:hover { color: var(--text); }
    .mobile-nav a.active { color: var(--text); font-weight: 700; background: var(--glass); }
    .fab { bottom: 70px; }
}

.mobile-stack { display: grid; grid-template-columns: 1fr; gap: 10px; }

.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
