:root {
  --green: #078a43;
  --green-dark: #056c35;
  --green-soft: #eaf7f0;
  --red: #e21c2a;
  --amber: #c48305;
  --ink: #151917;
  --muted: #6b7470;
  --line: #e4e9e6;
  --surface: #ffffff;
  --page: #f4f7f5;
  --sidebar: #151a18;
  --shadow: 0 12px 35px rgba(15, 30, 22, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--page); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--green); }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr); background: #fff; }
.login-brand-panel { position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: clamp(38px, 6vw, 84px); color: white; background: linear-gradient(145deg, #0d1612 0%, #16251e 45%, #04723a 100%); }
.brand-watermark { position: absolute; inset: 0; opacity: .08; background: repeating-linear-gradient(135deg, transparent 0 42px, rgba(255,255,255,.75) 42px 44px); }
.login-brand-panel::after { content: ""; position: absolute; width: 560px; height: 560px; right: -220px; top: -170px; border: 95px solid rgba(255,255,255,.07); border-radius: 50%; }
.brand-copy { position: relative; z-index: 1; max-width: 650px; }
.brand-copy .eyebrow { color: #7ee5a9; }
.brand-copy h1 { margin: 0; font-size: clamp(42px, 5vw, 76px); line-height: .98; letter-spacing: -.04em; max-width: 700px; }
.brand-copy > p { margin: 26px 0 38px; max-width: 600px; font-size: clamp(17px, 2vw, 22px); line-height: 1.55; color: rgba(255,255,255,.76); }
.brand-stats { display: flex; gap: 40px; flex-wrap: wrap; }
.brand-stats div { display: grid; gap: 4px; }
.brand-stats strong { font-size: 28px; }
.brand-stats span { font-size: 13px; color: rgba(255,255,255,.65); }
.login-card-wrap { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(510px, 100%); }
.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 24px; }
.login-logo { width: min(330px, 76%); height: auto; mix-blend-mode: multiply; }
.login-top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.demo-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 11px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.login-card h2 { margin: 0 0 8px; font-size: 28px; }
.login-card > .muted { margin: 0 0 22px; }
.language-select, select, input, textarea { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 10px; outline: none; }
.language-select { padding: 9px 12px; }
.language-select.compact { padding: 7px 10px; }
select:focus, input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(7,138,67,.12); }
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.role-card { display: flex; min-height: 92px; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--ink); text-align: left; transition: .18s ease; }
.role-card:hover, .role-card.selected { border-color: var(--green); background: var(--green-soft); transform: translateY(-1px); }
.role-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--green); color: white; }
.role-card span:last-child { display: grid; gap: 2px; }
.role-card small { color: var(--muted); font-size: 11px; }
.login-fields { display: grid; gap: 14px; margin: 22px 0 18px; }
.login-fields label, .filters-grid label, .modal-grid label { display: grid; gap: 7px; color: #44504b; font-size: 13px; font-weight: 700; }
.login-fields input { width: 100%; padding: 13px 14px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.password-wrap .icon-button { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.icon-button:hover { background: #edf1ef; color: var(--ink); }
.primary-button, .secondary-button { border-radius: 10px; padding: 11px 15px; border: 1px solid transparent; font-weight: 800; }
.primary-button { background: var(--green); color: white; }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { background: white; border-color: var(--line); color: var(--ink); }
.full { width: 100%; padding: 14px 18px; }
.login-note { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.login-note span:first-child { color: var(--green); }

.dashboard-view { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar); color: white; z-index: 30; }
.sidebar-brand { height: 100px; display: flex; align-items: center; padding: 14px 22px; border-bottom: 1px solid rgba(255,255,255,.08); background: white; }
.sidebar-brand img { width: 100%; height: 68px; object-fit: contain; }
.sidebar-nav { display: grid; gap: 4px; padding: 18px 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 10px; padding: 12px 14px; background: transparent; color: rgba(255,255,255,.68); text-align: left; }
.nav-item span:first-child { width: 22px; font-size: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.09); color: white; }
.nav-item.active::before { content: ""; width: 3px; height: 22px; margin-left: -14px; border-radius: 99px; background: #30cc77; }
.sidebar-footer { margin-top: auto; padding: 20px 24px; border-top: 1px solid rgba(255,255,255,.08); color: rgba(255,255,255,.55); }
.online-dot { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.online-dot span:first-child { width: 8px; height: 8px; border-radius: 50%; background: #36dc7d; box-shadow: 0 0 0 5px rgba(54,220,125,.12); }
.main-shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: 84px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: rgba(255,255,255,.95); backdrop-filter: blur(15px); border-bottom: 1px solid var(--line); }
.topbar-left, .topbar-actions, .profile-button { display: flex; align-items: center; }
.topbar-left h2 { margin: 0; font-size: 22px; }
.topbar-actions { gap: 10px; }
.notification-button { position: relative; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 11px; background: white; font-size: 20px; }
.notification-button span { position: absolute; top: -4px; right: -4px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--red); color: white; font-size: 10px; font-weight: 800; }
.profile-button { gap: 10px; border: 0; background: transparent; padding: 5px; color: var(--ink); text-align: left; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--green); color: white; font-size: 12px; font-weight: 900; }
.profile-copy { display: grid; gap: 2px; }
.profile-copy strong { font-size: 13px; }
.profile-copy small { color: var(--muted); }
.profile-menu { position: fixed; top: 72px; right: 24px; z-index: 70; width: 220px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); }
.profile-menu p { margin: 4px 8px 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.profile-menu button { display: block; width: 100%; border: 0; border-radius: 9px; padding: 9px 10px; background: white; text-align: left; }
.profile-menu button:hover { background: var(--green-soft); }
.profile-menu hr { border: 0; border-top: 1px solid var(--line); }
.content-section { display: none; padding: 24px 28px 38px; }
.active-section { display: block; }
.filter-panel { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 24px; margin-bottom: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.filter-title { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.filter-title > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 21px; }
.filter-title div { display: grid; gap: 3px; }
.filter-title small { color: var(--muted); font-weight: 400; }
.filters-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 12px; }
.filters-grid select { width: 100%; padding: 10px 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; min-height: 126px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.metric-card::after { content: ""; position: absolute; width: 58px; height: 58px; right: -19px; top: -19px; border-radius: 50%; background: var(--green-soft); }
.metric-card .metric-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric-card .metric-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--green-soft); color: var(--green); }
.metric-card .metric-change { font-size: 11px; font-weight: 800; color: var(--green); }
.metric-card strong { display: block; margin-top: 13px; font-size: clamp(21px, 2.2vw, 30px); letter-spacing: -.03em; }
.metric-card p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.metric-card.alert .metric-icon { background: #fff1f2; color: var(--red); }
.metric-card.alert .metric-change { color: var(--red); }
.dashboard-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.two-columns { grid-template-columns: minmax(0, 1.35fr) minmax(340px, .85fr); }
.panel { border: 1px solid var(--line); border-radius: 14px; background: white; padding: 19px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-header h3 { margin: 0 0 4px; font-size: 16px; }
.panel-header p { margin: 0; color: var(--muted); font-size: 12px; }
.positive-chip, .live-chip { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 6px 9px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; font-weight: 800; }
.live-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.text-button { border: 0; background: transparent; color: var(--green); font-weight: 800; font-size: 12px; }
.revenue-chart { min-height: 260px; }
.revenue-chart svg { width: 100%; height: 260px; overflow: visible; }
.chart-grid-line { stroke: #edf1ef; stroke-width: 1; }
.chart-area { fill: rgba(7,138,67,.09); }
.chart-line { fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { fill: white; stroke: var(--green); stroke-width: 3; }
.chart-label { fill: var(--muted); font-size: 11px; }
.ranking-list { display: grid; gap: 14px; }
.ranking-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.rank-number { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: #f1f4f2; color: var(--muted); font-size: 11px; font-weight: 900; }
.ranking-main { min-width: 0; }
.ranking-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 12px; }
.ranking-track, .progress-track { height: 8px; border-radius: 999px; background: #edf1ef; overflow: hidden; }
.ranking-fill, .progress-fill { height: 100%; border-radius: inherit; background: var(--green); }
.ranking-value { font-size: 12px; font-weight: 900; }
.region-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: stretch; }
.italy-map-demo { position: relative; min-height: 245px; overflow: hidden; border-radius: 14px; background: linear-gradient(145deg, #eff5f1, #e3eee7); }
.italy-map-demo::before { content: "ITALIA"; position: absolute; bottom: 20px; right: 20px; font-size: 40px; font-weight: 900; letter-spacing: .12em; color: rgba(0,0,0,.035); }
.map-region { position: absolute; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.85); color: white; box-shadow: 0 10px 25px rgba(7,80,40,.15); cursor: pointer; transition: .2s ease; }
.map-region:hover { transform: scale(1.04); }
.map-region span { font-size: 11px; font-weight: 800; }
.map-region b { font-size: 18px; }
.map-region.piemonte { left: 16%; top: 30%; width: 40%; height: 47%; border-radius: 52% 35% 45% 40%; background: var(--green-dark); }
.map-region.lombardia { right: 12%; top: 18%; width: 39%; height: 35%; border-radius: 45% 52% 38% 42%; background: #3f5c4d; }
.map-note { position: absolute; left: 12px; bottom: 10px; border-radius: 999px; padding: 6px 9px; background: rgba(255,255,255,.82); color: var(--muted); font-size: 10px; }
.region-stats { display: grid; gap: 13px; align-content: center; }
.region-stat { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.region-stat:last-child { border-bottom: 0; }
.region-stat-top { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12px; }
.region-stat strong { font-size: 18px; }
.client-performance { display: grid; gap: 18px; }
.client-card { display: grid; gap: 9px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.client-card-top { display: flex; align-items: center; justify-content: space-between; }
.client-logo { display: grid; place-items: center; width: 44px; height: 32px; border-radius: 8px; background: #f1f4f2; font-size: 11px; font-weight: 900; }
.client-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.client-numbers div { display: grid; gap: 2px; }
.client-numbers strong { font-size: 15px; }
.client-numbers span { color: var(--muted); font-size: 10px; }
.table-header { align-items: center; }
.table-actions { display: flex; align-items: center; gap: 10px; }
.table-actions input { width: 210px; padding: 10px 11px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 870px; }
th { padding: 11px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 13px 12px; border-bottom: 1px solid #eef1ef; font-size: 12px; }
tbody tr:hover { background: #fbfdfc; }
.driver-cell { display: flex; align-items: center; gap: 9px; }
.driver-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--green-soft); color: var(--green-dark); font-weight: 900; }
.status-badge { display: inline-flex; border-radius: 999px; padding: 5px 8px; background: var(--green-soft); color: var(--green-dark); font-size: 10px; font-weight: 900; }
.status-badge.warning { background: #fff7e8; color: var(--amber); }
.status-badge.danger { background: #fff0f1; color: var(--red); }
.driver-personal { display: grid; gap: 18px; }
.driver-hero { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 26px; border-radius: 16px; background: linear-gradient(135deg, #121d17, #087b3e); color: white; }
.driver-hero::after { content: ""; position: absolute; width: 240px; height: 240px; right: -75px; top: -110px; border: 55px solid rgba(255,255,255,.08); border-radius: 50%; }
.driver-hero h3 { margin: 4px 0 8px; font-size: 28px; }
.driver-hero p { margin: 0; color: rgba(255,255,255,.72); }
.driver-hero .avatar { width: 62px; height: 62px; font-size: 18px; background: white; color: var(--green-dark); }
.driver-amount { position: relative; z-index: 1; text-align: right; }
.driver-amount strong { display: block; font-size: 34px; }
.driver-amount span { color: rgba(255,255,255,.7); font-size: 12px; }
.empty-page { display: grid; gap: 18px; }
.page-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.page-hero h3 { margin: 0 0 5px; }
.page-hero p { margin: 0; color: var(--muted); }
.cards-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.entity-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.entity-card h4 { margin: 0 0 5px; }
.entity-card p { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.entity-meta { display: grid; gap: 8px; }
.entity-meta div { display: flex; justify-content: space-between; gap: 14px; font-size: 12px; }
.entity-meta span { color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(10,17,13,.65); }
.modal-card { width: min(720px, 100%); max-height: 92vh; overflow-y: auto; padding: 22px; border-radius: 16px; background: white; box-shadow: 0 28px 70px rgba(0,0,0,.25); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { margin: 0; }
.modal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.modal-grid input, .modal-grid select, .modal-grid textarea { width: 100%; padding: 11px 12px; }
.modal-grid .wide { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.success-message { margin-top: 14px; padding: 11px 13px; border-radius: 10px; background: var(--green-soft); color: var(--green-dark); font-size: 13px; font-weight: 800; }

[dir="rtl"] .topbar-left, [dir="rtl"] .topbar-actions, [dir="rtl"] .profile-button, [dir="rtl"] .filter-title, [dir="rtl"] .driver-cell { flex-direction: row-reverse; }
[dir="rtl"] .profile-menu { right: auto; left: 24px; }
[dir="rtl"] th, [dir="rtl"] td, [dir="rtl"] .profile-button { text-align: right; }
[dir="rtl"] .nav-item { text-align: right; }

@media (max-width: 1240px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .two-columns { grid-template-columns: 1fr; }
  .cards-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 46vh; }
  .dashboard-view { display: block; }
  .mobile-only { display: grid; }
  .sidebar { position: fixed; left: -270px; width: 250px; transition: left .2s ease; box-shadow: 20px 0 45px rgba(0,0,0,.2); }
  .sidebar.open { left: 0; }
  [dir="rtl"] .sidebar { left: auto; right: -270px; transition: right .2s ease; }
  [dir="rtl"] .sidebar.open { right: 0; }
  .sidebar-brand { justify-content: space-between; }
  .sidebar-brand img { width: 170px; }
  .topbar { padding: 0 16px; }
  .profile-copy { display: none; }
  .content-section { padding: 18px 16px 28px; }
  .filter-panel { grid-template-columns: 1fr; }
  .filters-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .login-brand-panel { padding: 36px 24px; }
  .login-card-wrap { padding: 24px 18px; }
  .role-grid { grid-template-columns: 1fr; }
  .role-card { min-height: 70px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { min-height: 118px; }
  .filters-grid { grid-template-columns: 1fr; }
  .region-layout { grid-template-columns: 1fr; }
  .table-header, .table-actions { align-items: stretch; flex-direction: column; }
  .table-actions input { width: 100%; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-grid .wide { grid-column: auto; }
  .cards-list { grid-template-columns: 1fr; }
  .driver-hero { align-items: flex-start; flex-direction: column; }
  .driver-amount { text-align: left; }
  [dir="rtl"] .driver-amount { text-align: right; }
}
