/* Unico Arredi Business Manager — self-contained design system (no build, no CDN). */
:root {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1e222b; --border: #2a2f3a;
    --text: #e7e9ee; --muted: #9aa3b2; --primary: #4f7cff; --primary-2: #3d63d8;
    --green: #2fbf71; --red: #ef4d5a; --amber: #f5a524; --radius: 12px;
    --sidebar-w: 240px; --shadow: 0 6px 24px rgba(0,0,0,.28);
}
@media (prefers-color-scheme: light) {
    :root { --bg:#f4f6fb; --surface:#fff; --surface-2:#f0f3f9; --border:#e2e6ee;
        --text:#1b2130; --muted:#5c6675; --shadow:0 6px 20px rgba(20,30,60,.08); }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
    position: fixed; top: 0; bottom: 0; left: 0; padding: 18px 12px; overflow-y: auto; }
.sidebar .brand { font-weight: 750; font-size: 16px; padding: 6px 10px 16px; display: flex; align-items: center; gap: 8px; }
.sidebar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.nav-group { margin: 14px 0 6px; padding: 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text);
    font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 58px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
    justify-content: space-between; padding: 0 24px; background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 650; font-size: 13px; }
.content { padding: 24px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3,.grid.cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px) { .grid.cols-2,.grid.cols-3,.grid.cols-4 { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 30; }
    .sidebar.open { transform: none; } .main { margin-left: 0; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi .value.pos { color: var(--green); } .kpi .value.neg { color: var(--red); }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Badges & buttons */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.green { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.badge.red { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.badge.amber { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.badge.blue { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 11px; font-size: 12px; }

/* Forms */
.form-row { margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--bg); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.error { color: var(--red); font-size: 12px; margin-top: 5px; }
.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; border: 1px solid; }
.alert.error { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: var(--red); color: var(--red); }
.alert.ok { background: color-mix(in srgb, var(--green) 12%, transparent); border-color: var(--green); color: var(--green); }
.alert.warn { background: color-mix(in srgb, var(--amber) 12%, transparent); border-color: var(--amber); color: var(--amber); }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { text-align: center; font-size: 22px; font-weight: 750; margin-bottom: 6px; }

/* AI chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 160px); }
.chat-log { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 75%; padding: 11px 14px; border-radius: 14px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.tool { align-self: flex-start; background: transparent; border: 1px dashed var(--border); color: var(--muted); font-size: 12px; }
.chat-input { display: flex; gap: 10px; margin-top: 12px; }
.chat-input input { flex: 1; }
.action-card { border: 1px solid var(--amber); border-radius: 9px; padding: 12px; margin-top: 8px; }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.gap { gap: 10px; } .mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .right { text-align: right; }
