:root {
    --ink: #1f2033; --soft: #8b8ca3; --line: #eef0f6; --bg-soft: #f7f6fb;
    --purple: #7c6fe0; --purple-dk: #6355c7; --herb: #3fb27f; --paprika: #e8622e;
    --warn: #f0a83a; --danger: #e0455a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: #f7f7fb; }
a { color: inherit; }

.app-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.app-sidebar {
    background: #fff; border-right: 1px solid var(--line); padding: 22px 14px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
}
.app-brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 22px; }
.app-brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #ff7a45, #ec4899); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 13px; }
.app-brand-name { font-weight: 800; font-size: 15px; }
.app-brand-sub { font-size: 10.5px; color: var(--soft); margin-top: 1px; }
.app-sidebar-close { display: none; margin-left: auto; cursor: pointer; }

.nav-group { padding: 18px 10px 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: #b5b6c4; }
.nav-sep { height: 1px; background: var(--line); margin: 14px 4px 10px; }
.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin-bottom: 3px;
    border-radius: 11px; font-size: 13.5px; font-weight: 500; color: #5a5b72; text-decoration: none; position: relative;
}
.nav-item:hover { background: var(--bg-soft); }
.nav-item.active { background: linear-gradient(90deg, #fff2ec, #fff); color: var(--paprika); font-weight: 700; }
.nav-item.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; background: #ff7a45; border-radius: 3px; }
.nav-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-topbar { display: flex; align-items: center; gap: 14px; padding: 16px 30px; border-bottom: 1px solid var(--line); background: #fff; }
.app-hamburger { display: none; font-size: 20px; cursor: pointer; }
.app-search-wrap { flex: 1; }
.app-search { width: 100%; max-width: 380px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.app-bell { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; font-family: inherit; padding: 0; }
.app-bell .dot { position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; border-radius: 50%; background: #ff7a45; color: #fff; font-size: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.app-user { display: flex; align-items: center; gap: 9px; background: none; border: none; cursor: pointer; font-family: inherit; padding: 4px; border-radius: 10px; text-align: left; }
.app-user:hover, .app-bell:hover { background: var(--bg-soft); }
.app-bell .dot { position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; border-radius: 50%; background: #ff7a45; color: #fff; font-size: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.app-user-name { font-size: 13px; font-weight: 700; }
.app-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--purple), #ec4899); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 12.5px; flex-shrink: 0; }
.app-user-role { font-size: 10.5px; color: var(--soft); }

/* ---------- Notification & profile dropdowns ---------- */
.app-dropdown-wrap { position: relative; flex-shrink: 0; }
.app-dropdown {
    display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0,0,0,.12); z-index: 60; overflow: hidden;
}
.app-dropdown.show { display: block; }
.app-dropdown-head { padding: 10px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--soft); border-bottom: 1px solid #f5f5fa; }
.app-dropdown-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 13px; color: var(--ink); text-decoration: none; border-bottom: 1px solid #f5f5fa; }
.app-dropdown-item:last-child { border-bottom: none; }
.app-dropdown-item:hover { background: #faf9fd; }
.app-dropdown-empty { padding: 16px 14px; font-size: 12.5px; color: var(--soft); text-align: center; }
.app-dropdown-footer { display: block; padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--purple); text-decoration: none; text-align: center; background: #faf9fd; }
.app-user-role a { font-size: 10.5px; color: var(--soft); text-decoration: none; }
.app-content { padding: 22px 30px 30px; flex: 1; min-width: 0; }
.app-backdrop { display: none; }

.hero h1 { margin: 0 0 4px; font-size: 22px; }
.tag { font-size: 12px; color: var(--soft); }

.stats { display: grid; gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border-radius: 14px; padding: 16px 18px; border: 1px solid var(--line); }
.stat .label { font-size: 11.5px; color: var(--soft); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.stat .value { font-size: 20px; font-weight: 800; }
.stat .sub { font-size: 11px; color: var(--soft); margin-top: 2px; }
.accent-herb .value { color: var(--herb); } .accent-paprika .value { color: var(--paprika); }
.accent-warn .value { color: var(--warn); } .accent-danger .value { color: var(--danger); }

.panel { background: #fff; border-radius: 16px; border: 1px solid var(--line); margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-body { padding: 20px; }
.empty { padding: 30px; text-align: center; color: var(--soft); font-size: 13px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; align-items: start; }
.field { display: flex; flex-direction: column; }
.field label { font-size: 12px; font-weight: 600; color: var(--soft); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.field input, .field select {
    height: 42px; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--bg-soft); font-size: 13px; color: var(--ink); font-family: inherit; box-sizing: border-box;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--purple); background: #fff; box-shadow: 0 0 0 3px rgba(124,111,224,.12); }

.btn { display: inline-block; padding: 10px 18px; font-size: 13px; font-weight: 700; border-radius: 10px; border: none; cursor: pointer; text-decoration: none; }
.btn.paprika { background: var(--purple); color: #fff; }
.btn.secondary { background: var(--bg-soft); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 12px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 700; font-size: 11px; color: var(--soft); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafd; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; background: #f0f0f5; }
.badge.low { background: #ffe9e2; color: var(--paprika); }
.note { font-size: 12px; color: var(--soft); line-height: 1.5; }

.toast { position: fixed; bottom: 24px; right: 24px; left: 24px; max-width: 420px; margin-left: auto; background: var(--ink); color: #fff; padding: 12px 20px; font-size: 13px; line-height: 1.45; border-radius: 12px; z-index: 9999; box-shadow: 0 8px 24px rgba(0,0,0,.28); display: none; word-wrap: break-word; }
.toast.show { display: block; }
.toast.error { background: var(--danger); }

/* ---------- Tooltips ---------- */
.tip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 50%;
    background: #eef0f6; color: var(--soft);
    font-size: 10px; font-weight: 700; font-style: normal;
    cursor: help; flex-shrink: 0; user-select: none;
}
.tip:hover, .tip.show { background: var(--purple); color: #fff; }
.global-tooltip {
    display: none; position: fixed; background: #1f2033; color: #fff;
    padding: 8px 11px; border-radius: 8px; font-size: 11.5px; font-weight: 500;
    line-height: 1.45; max-width: 230px; z-index: 9999;
    box-shadow: 0 6px 18px rgba(0,0,0,.22); text-align: left; pointer-events: none;
}
.global-tooltip.show { display: block; }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-soft); }
.auth-card { background: #fff; padding: 36px; border-radius: 18px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card .sub { color: var(--soft); font-size: 13px; margin-bottom: 22px; }
.auth-error { background: #ffe9e2; color: var(--paprika); padding: 10px 14px; border-radius: 10px; font-size: 12.5px; margin-bottom: 16px; }

@media (max-width: 1000px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .app-sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 260px; max-width: 82vw; z-index: 100; transform: translateX(-100%); transition: transform .22s ease; overflow-y: auto; }
    .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-shell.sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; background: rgba(20,20,30,.4); z-index: 90; }
    .app-sidebar-close { display: block; }
    .app-hamburger { display: block; }
    .app-topbar { padding: 14px 16px; }
    .app-content { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}
