/* ============================================================
   OrçaPRO — Design System v2
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- DARK THEME (padrão) --------------------------------- */
:root {
  --bg:         #111114;
  --bg2:        #18181c;
  --card:       #1e1e24;
  --card-hover: #26262e;
  --border:     #2e2e38;
  --text:       #f0f0f4;
  --text-muted: #8888a0;
  --text-dim:   #55555f;
  --input-bg:   #15151a;

  --brand-teal:    #00b894;
  --brand-teal-lt: #00d4a8;
  --brand-orange:  #e17055;
  --brand-dark:    #0d3d2e;

  --sidebar-w:  220px;
  --topbar-h:   56px;
  --radius:     12px;
  --shadow:     0 4px 24px rgba(0,0,0,.5);
  --shadow-sm:  0 2px 8px rgba(0,0,0,.3);
  --transition: .2s ease;
}

/* ---- LIGHT THEME ----------------------------------------- */
[data-theme="light"] {
  --bg:         #f5f9f7;
  --bg2:        #ffffff;
  --card:       #ffffff;
  --card-hover: #f0f8f4;
  --border:     #d0e8dc;
  --text:       #0d3d2e;
  --text-muted: #3a7a5c;
  --text-dim:   #8ab8a0;
  --input-bg:   #f8fdfa;
  --shadow:     0 4px 24px rgba(13,61,46,.10);
  --shadow-sm:  0 2px 8px rgba(13,61,46,.07);
}

/* ---- RESET ----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--brand-teal); text-decoration: none; }
a:hover { color: var(--brand-teal-lt); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ---- SIDEBAR --------------------------------------------- */
.sidebar {
  position: fixed; left: 0; top: 0;
  width: var(--sidebar-w); height: 100vh;
  background: #0e0e12;
  border-right: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
[data-theme="light"] .sidebar {
  background: #0d3d2e;
  border-right: 1px solid rgba(0,0,0,.1);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.logo-img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.logo-text {
  width: 34px; height: 34px;
  background: var(--brand-teal); color: #0d3d2e;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.logo-name { font-weight: 700; font-size: 14px; color: #fff; }
.sidebar-nav {
  flex: 1; padding: 10px 8px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,.5); font-size: 14px; font-weight: 500;
  transition: all var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--brand-teal); color: #0d3d2e; font-weight: 700; }
.nav-item.active svg { stroke: #0d3d2e; }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 8px;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--brand-teal); color: #0d3d2e;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-name    { display: block; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-empresa { display: block; font-size: 11px; color: rgba(255,255,255,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout   { padding: 5px; border-radius: 6px; color: rgba(255,255,255,.35); display: flex; transition: all var(--transition); }
.btn-logout:hover { background: rgba(239,68,68,.2); color: #ff7675; }

/* ---- TOPBAR ---------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 14px;
  z-index: 90;
  transition: left var(--transition), background var(--transition);
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 6px; }
.btn-theme {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 15px;
  transition: all var(--transition);
}
.btn-theme:hover { border-color: var(--brand-teal); }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }

/* ---- MAIN CONTENT ---------------------------------------- */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  padding-bottom: 40px;
  background: var(--bg);
  transition: background var(--transition);
}
.page-body { padding: 24px 24px 0; }

/* ---- CARDS ----------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}
.card-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.card-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- KPI CARDS ------------------------------------------- */
.kpi-wrap {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.kpi {
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  border: none;
  box-shadow: 0 4px 18px rgba(0,0,0,.3);
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: '';
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 3px;
  background: rgba(255,255,255,.4);
  border-radius: 2px;
}
.kpi-lbl {
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,.9);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 10px; line-height: 1.3;
}
.kpi-num {
  font-size: 40px; font-weight: 800;
  color: #fff; line-height: 1;
}
.kpi-num-sm {
  font-size: 22px; font-weight: 800;
  color: #fff; line-height: 1.1;
}
.kpi-a { background: #d95f2b; }
.kpi-b { background: #5b2c8c; }
.kpi-c { background: #145c32; }
.kpi-d { background: #00b894; }

/* ---- GRIDS ----------------------------------------------- */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

/* ---- BOTÕES ---------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn-primary       { background: var(--brand-teal); color: #0d3d2e; }
.btn-primary:hover { background: var(--brand-teal-lt); color: #0d3d2e; }
.btn-secondary      { background: var(--card); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover{ border-color: var(--brand-teal); color: var(--brand-teal); }
.btn-orange         { background: var(--brand-orange); color: #fff; border: none; }
.btn-orange:hover   { background: #ea896e; color: #fff; }
.btn-danger         { background: rgba(239,68,68,.12); color: #ef4444; border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover   { background: rgba(239,68,68,.22); }
.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-lg  { padding: 12px 28px; font-size: 15px; }

/* ---- SECTION HEADER (laranja) ---------------------------- */
.sec-header {
  background: #e17055;
  color: #fff;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 16px; border-radius: 8px;
  margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.sec-header a { color: #fff; font-size: 12px; opacity: .85; text-decoration: underline; }

/* ---- FORMULÁRIOS ----------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 9px 13px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
  font-family: 'Inter', sans-serif; transition: border-color var(--transition);
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--brand-teal); box-shadow: 0 0 0 3px rgba(0,184,148,.1); }
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ---- TABELAS --------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 11px 14px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--card-hover); }

/* ---- BADGES ---------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green  { background: rgba(0,184,148,.15);  color: #00b894; }
.badge-yellow { background: rgba(245,158,11,.15); color: #d4a017; }
.badge-red    { background: rgba(239,68,68,.15);  color: #ef4444; }
.badge::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }

/* ---- ALERTAS --------------------------------------------- */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; }
.alert-success { background: rgba(0,184,148,.12); color: #00b894; border: 1px solid rgba(0,184,148,.3); }
.alert-error   { background: rgba(239,68,68,.12); color: #ef4444; border: 1px solid rgba(239,68,68,.3); }
.alert-info    { background: rgba(225,112,85,.12); color: #e17055; border: 1px solid rgba(225,112,85,.3); }

/* ---- SEARCH BAR ------------------------------------------ */
.search-bar { position: relative; max-width: 320px; }
.search-bar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }
.search-bar input { padding-left: 38px; }

/* ---- PAGE HEADER ----------------------------------------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 18px; font-weight: 700; }

/* ---- ORÇAMENTO ITENS ------------------------------------- */
.item-row { display: grid; grid-template-columns: 2fr 2fr 70px 110px 90px 36px; gap: 8px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.item-row:last-child { border-bottom: none; }
.orcamento-totals { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; text-align: right; }
.totals-row { display: flex; justify-content: flex-end; gap: 20px; margin-bottom: 6px; font-size: 14px; }
.totals-row span:first-child { color: var(--text-muted); }
.total-final { font-size: 22px; font-weight: 800; color: var(--brand-teal); }

/* ---- PREVIEW ORÇAMENTO ----------------------------------- */
.preview-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; font-size: 13px; line-height: 1.6; }
.preview-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.preview-logo-box { width: 52px; height: 52px; background: #26262e; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; color: var(--brand-teal); }
.preview-numero { font-size: 20px; font-weight: 800; color: var(--brand-teal); }
.preview-section { margin-bottom: 14px; }
.preview-section h4 { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 4px; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.preview-table th { background: var(--bg); padding: 6px 8px; text-align: left; font-size: 10px; text-transform: uppercase; color: var(--text-muted); }
.preview-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.preview-total { text-align: right; margin-top: 10px; font-size: 18px; font-weight: 800; color: var(--brand-teal); }

/* ---- LOGIN ----------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0e0e12; padding: 20px; }
[data-theme="light"] .login-wrap { background: #0d3d2e; }
.login-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 16px; padding: 36px 32px; box-shadow: var(--shadow);
}
[data-theme="light"] .login-card { background: #fff; border-color: #d0e8dc; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 26px; font-weight: 800; color: var(--brand-teal); }
.login-logo p { font-size: 13px; color: rgba(255,255,255,.45); margin-top: 4px; }
[data-theme="light"] .login-logo p { color: var(--text-muted); }
.login-wrap .form-label { color: rgba(255,255,255,.65); }
[data-theme="light"] .login-wrap .form-label { color: var(--text-muted); }
.login-wrap .form-control { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.1); color: #fff; }
[data-theme="light"] .login-wrap .form-control { background: var(--input-bg); border-color: var(--border); color: var(--text); }

/* ---- ORÇAMENTO PÚBLICO ----------------------------------- */
.public-wrap { max-width: 760px; margin: 40px auto; padding: 0 20px; }
.public-doc { background: #fff; color: #1a1a1a; border-radius: 12px; padding: 40px; box-shadow: 0 8px 40px rgba(0,0,0,.15); }
.public-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---- MODALS ---------------------------------------------- */
.modal-overlay {
  display: none; position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,.7);
  z-index: 9999; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  width: 90%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow); position: relative; z-index: 10000;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---- UTILS ----------------------------------------------- */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-green  { color: var(--brand-teal); }
.text-orange { color: var(--brand-orange); }
.text-red    { color: #ef4444; }
.mt-1{margin-top:8px} .mt-2{margin-top:16px} .mt-3{margin-top:24px}
.mb-2{margin-bottom:16px} .mb-3{margin-bottom:24px}
.flex{display:flex} .gap-2{gap:10px} .items-center{align-items:center}
.justify-between{justify-content:space-between} .w-full{width:100%}
.hidden{display:none!important}
.divider{border:none;border-top:1px solid var(--border);margin:18px 0}

/* ---- SCROLLBAR ------------------------------------------- */
::-webkit-scrollbar{width:5px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}

/* ---- RESPONSIVO ------------------------------------------ */
@media(max-width:1024px){
  .grid-4{grid-template-columns:repeat(2,1fr)}
  .grid-3{grid-template-columns:repeat(2,1fr)}
  .kpi-wrap{grid-template-columns:repeat(2,1fr)}
}
@media(max-width:768px){
  .sidebar{transform:translateX(-100%)}
  .sidebar.open{transform:translateX(0)}
  .topbar{left:0}
  .main-content{margin-left:0}
  .btn-menu-toggle{display:flex}
  .grid-4,.grid-3,.grid-2{grid-template-columns:1fr}
  .page-body{padding:14px}
  .item-row{grid-template-columns:1fr 1fr}
}
@media(max-width:600px){
  .kpi-wrap{grid-template-columns:1fr}
}
@media(max-width:480px){
  .login-card{padding:24px 18px}
  .item-row{grid-template-columns:1fr}
}
@media print{
  .sidebar,.topbar,.btn,.public-actions{display:none!important}
  .main-content{margin:0;padding:0}
  .public-doc{box-shadow:none}
}