/* ═══════════════════════════════════════════════════
   MILHORIN — Layout estilo AdminLTE  (v11)
   CSS próprio, funciona 100% offline
═══════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Marca */
  --blue:        #3c8dbc;
  --blue-dark:   #367fa9;
  --blue-light:  #d9eaf7;
  --blue-mid:    #5ba3cc;

  /* Sidebar */
  --sidebar-bg:      #222d32;
  --sidebar-hover:   #1a2226;
  --sidebar-active:  #1e282c;
  --sidebar-text:    #b8c7ce;
  --sidebar-active-text: #ffffff;
  --sidebar-section: #4b646f;
  --sidebar-w:       230px;
  --topbar-h:        50px;

  /* Semânticas */
  --green:       #00a65a;
  --green-light: #dff0d8;
  --amber:       #f39c12;
  --amber-light: #fef3cd;
  --red:         #dd4b39;
  --red-light:   #f2dede;
  --purple:      #605ca8;
  --purple-light:#e8e7f5;
  --teal:        #00c0ef;
  --teal-light:  #d1f4fd;

  /* UI geral */
  --text:        #333;
  --text-muted:  #777;
  --border:      #d2d6de;
  --bg:          #ecf0f5;
  --white:       #ffffff;
  --radius:      4px;
  --radius-lg:   4px;
  --shadow:      0 1px 3px rgba(0,0,0,.12);
}

body {
  font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--blue);
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.topbar-logo {
  width: var(--sidebar-w);
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .3px;
  flex-shrink: 0;
}
.topbar-logo .logo-icon {
  width: 33px; height: 33px;
  background: rgba(255,255,255,.2);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: white;
}
.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.8);
  font-size: 13px;
}
.topbar-right span { color: white; font-weight: 500; }

/* ═══════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  padding-bottom: 20px;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.nav-links { list-style: none; padding: 8px 0; }

.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--sidebar-section);
  text-transform: uppercase;
  letter-spacing: .7px;
  padding: 14px 16px 4px;
  list-style: none;
}
.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.nav-links a:hover {
  background: var(--sidebar-hover);
  color: white;
}
.nav-links a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
  border-left-color: var(--blue);
  font-weight: 500;
}
.nav-links a svg { flex-shrink: 0; opacity: .8; }
.nav-links a.active svg,
.nav-links a:hover svg { opacity: 1; }

/* ═══════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 20px 24px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ═══════════════════════════════════════════════════
   FLASH MESSAGES
═══════════════════════════════════════════════════ */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-success { background: var(--green-light);  color: #3c763d; border-color: #d6e9c6; }
.flash-error   { background: var(--red-light);    color: #a94442; border-color: #ebccd1; }

/* ═══════════════════════════════════════════════════
   PAGE HEADER (breadcrumb-style)
═══════════════════════════════════════════════════ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
}

/* ═══════════════════════════════════════════════════
   INFO-BOXES (cards coloridos estilo AdminLTE)
═══════════════════════════════════════════════════ */
.info-box {
  display: flex;
  align-items: stretch;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 80px;
}
.info-box-icon {
  width: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  color: white;
}
.info-box-icon.bg-blue    { background: var(--blue); }
.info-box-icon.bg-green   { background: var(--green); }
.info-box-icon.bg-amber   { background: var(--amber); }
.info-box-icon.bg-red     { background: var(--red); }
.info-box-icon.bg-purple  { background: var(--purple); }
.info-box-icon.bg-teal    { background: var(--teal); }

.info-box-content {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.info-box-text {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.info-box-number {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.info-box-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════
   METRIC CARDS (grid simples)
═══════════════════════════════════════════════════ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.info-boxes-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.metric-label  { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.metric-value  { font-size: 26px; font-weight: 700; }
.metric-sub    { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ═══════════════════════════════════════════════════
   SECTION CARDS (box / panel)
═══════════════════════════════════════════════════ */
.section-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #f9f9f9;
  font-weight: 600;
  font-size: 14px;
}
.card-header .card-title { font-size: 15px; font-weight: 600; color: var(--text); }

/* ═══════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: #fafafa;
  white-space: nowrap;
}
.data-table td { padding: 9px 16px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f5f8fb; }
.empty-cell { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ═══════════════════════════════════════════════════
   PRIORITY BAR
═══════════════════════════════════════════════════ */
.priority-bar { width: 4px; height: 32px; border-radius: 2px; }
.priority-critica  { background: var(--red); }
.priority-atrasada { background: var(--red); }
.priority-urgente  { background: var(--amber); }
.priority-normal   { background: var(--blue-mid); }
.priority-concluida{ background: var(--green); }

/* ═══════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: var(--green-light);  color: #3c763d; }
.badge-blue   { background: var(--blue-light);   color: var(--blue-dark); }
.badge-amber  { background: var(--amber-light);  color: #8a6d3b; }
.badge-red    { background: var(--red-light);    color: #a94442; }
.badge-gray   { background: #f4f4f4;             color: #555; }
.badge-teal   { background: var(--teal-light);   color: #0097b5; }

/* ═══════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-primary   { background: var(--blue);   color: white; border-color: var(--blue-dark); }
.btn-secondary { background: #6c757d;       color: white; border-color: #5a6268; }
.btn-success   { background: var(--green);  color: white; border-color: #008d4c; }
.btn-warning   { background: var(--amber);  color: white; border-color: #e08e0b; }
.btn-danger    { background: var(--red);    color: white; border-color: #d73925; }
.btn-ghost     { background: transparent;   border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); opacity: 1; }
.btn-xs  { padding: 3px 9px;  font-size: 11px; }
.btn-sm  { padding: 5px 12px; font-size: 12px; }
.form-inline-del { display: inline; }

/* ═══════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════ */
.form-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 860px;
}
.form-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 4px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full-width { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-field input,
.form-field select,
.form-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: white;
  font-family: inherit;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(60,141,188,.15); }
.form-field textarea { resize: vertical; }
.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 20px 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════
   SEARCH & FILTER
═══════════════════════════════════════════════════ */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.input-search { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.filter-search-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-tab {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: white;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
}
.filter-tab:hover { background: var(--bg); }
.filter-tab.active { background: var(--blue); color: white; border-color: var(--blue-dark); font-weight: 500; }
.search-inline { display: flex; gap: 6px; }
.search-inline input { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; width: 220px; }

/* ═══════════════════════════════════════════════════
   DETAIL LAYOUT
═══════════════════════════════════════════════════ */
.detail-layout { display: flex; flex-direction: column; gap: 0; }
.detail-header-block { display: flex; align-items: center; gap: 14px; padding: 16px; border-bottom: 1px solid var(--border); }
.detail-header-block h2 { font-size: 18px; font-weight: 600; }
.detail-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 4px 0; }
.field { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.field label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.field span { font-size: 13px; }
.observacoes { padding: 12px 16px; border-top: 1px solid var(--border); }
.observacoes label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.observacoes p { font-size: 13px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════
   AVATAR
═══════════════════════════════════════════════════ */
.avatar    { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-light); color: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }

/* ═══════════════════════════════════════════════════
   SERVICES GRID
═══════════════════════════════════════════════════ */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.svc-card { background: white; border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; box-shadow: var(--shadow); }
.svc-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.svc-name { font-weight: 600; font-size: 14px; }
.svc-meta { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.svc-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════
   FINANCEIRO INLINE
═══════════════════════════════════════════════════ */
.recibo-form { padding: 12px 16px; border-top: 1px solid var(--border); background: #fafafa; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.inline-form input, .inline-form select { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.inline-form input[type=number] { width: 130px; }
.inline-form input[type=date]   { width: 140px; }

/* ═══════════════════════════════════════════════════
   MÉTRICAS CLIENTE
═══════════════════════════════════════════════════ */
.metricas-cliente { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--border); }
.metrica-item { padding: 16px; border-right: 1px solid var(--border); text-align: center; }
.metrica-item:last-child { border-right: none; }
.metrica-valor { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.metrica-label { font-size: 11px; color: var(--text-muted); }
.metrica-sub { font-size: 11px; color: var(--amber); margin-top: 2px; }

/* ═══════════════════════════════════════════════════
   OS FILTER BAR
═══════════════════════════════════════════════════ */
.os-filter-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.os-filters-extra { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.os-filters-extra select { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: white; }
.os-filters-extra input  { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; min-width: 220px; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.active-filter-tag { background: var(--blue-light); color: var(--blue); padding: 3px 10px; border-radius: 3px; font-size: 12px; }
.active-filter-tag a { color: var(--blue); text-decoration: none; margin-left: 4px; font-weight: 600; }

/* ═══════════════════════════════════════════════════
   PROCESS SEARCH
═══════════════════════════════════════════════════ */
.process-search-bar { display: flex; flex-direction: column; gap: 4px; }
.process-search-bar input { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; width: 100%; }
.process-results { border: 1px solid var(--border); border-radius: var(--radius); background: white; max-height: 240px; overflow-y: auto; margin-top: 4px; box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.process-result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.process-result-item:last-child { border-bottom: none; }
.process-result-item:hover { background: var(--bg); }
.pr-title { font-weight: 500; font-size: 13px; }
.pr-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.process-result-empty { padding: 12px 14px; font-size: 13px; color: var(--text-muted); }
.contrato-info-box { margin-top: 8px; padding: 8px 12px; background: var(--blue-light); border-radius: var(--radius); font-size: 13px; }

/* ═══════════════════════════════════════════════════
   HELPERS
═══════════════════════════════════════════════════ */
.calc-result { font-size: 18px; font-weight: 600; padding: 8px 0; }
.flex-row    { display: flex; align-items: center; }
.gap-sm      { gap: 8px; }
.fw-500      { font-weight: 500; }
.text-sm     { font-size: 12px; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--red); }
.text-success{ color: var(--green); }
.text-warning{ color: var(--amber); }
.text-center { text-align: center; }
.link        { color: var(--blue); text-decoration: none; }
.link:hover  { text-decoration: underline; }
.link-muted  { color: var(--text-muted); font-size: 12px; text-decoration: none; }
.link-muted:hover { text-decoration: underline; }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); background: white; border-radius: var(--radius); border: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════
   BULK ACTION BAR
═══════════════════════════════════════════════════ */
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--blue);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.bulk-action-bar span { font-size: 14px; font-weight: 600; }

/* ═══════════════════════════════════════════════════
   SORTABLE HEADERS
═══════════════════════════════════════════════════ */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #f0f0f0; }
th.sortable .sort-arrow { font-size: 10px; opacity: .6; }

/* ═══════════════════════════════════════════════════
   TIME TRACKER
═══════════════════════════════════════════════════ */
.timer-card { padding: 20px 24px; }
.timer-card-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.timer-card-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.timer-clock { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--text); font-family: 'SF Mono', 'Fira Code', monospace; }
.timer-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timer-display .timer-val { font-size: 12px; font-weight: 600; }
.timer-inline { display: flex; align-items: center; gap: 6px; }
.timer-val-sm { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 42px; }
.timer-btn { padding: 2px 6px !important; font-size: 11px !important; }

/* ═══════════════════════════════════════════════════
   CHECKBOX
═══════════════════════════════════════════════════ */
.row-chk { width: 15px; height: 15px; cursor: pointer; accent-color: var(--blue); }
