@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #F2F1EE;
  --surface: #FAFAF8;
  --surface2: #EFEDE9;
  --border: #D8D5CF;
  --border-strong: #B8B4AC;
  --text: #1A1916;
  --text-2: #5C5A55;
  --text-3: #9B9890;
  --primary: #2D5A3D;
  --primary-light: #E8F0EB;
  --primary-mid: #4A8C62;
  --accent: #C4A35A;
  --danger: #C0392B;
  --danger-light: #FDECEA;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --success: #2D5A3D;
  --success-light: #E8F0EB;
  --info: #1D4E7A;
  --info-light: #E8F2FB;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --sidebar-w: 240px;
  --header-h: 64px;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0;
}
.sidebar-logo .logo-text { font-size: .8rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.sidebar-logo .logo-text span { display: block; font-weight: 400; color: var(--text-3); font-size: .7rem; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { margin-bottom: 20px; }
.nav-section-label { font-size: .65rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 0 10px; margin-bottom: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: .875rem; font-weight: 450;
  text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
  border: 1.5px solid transparent;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-color: #C5D9CA; font-weight: 600; }
.nav-item .nav-icon { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: .65rem; font-weight: 700; padding: 1px 6px; border-radius: 99px;
}

.sidebar-footer { padding: 12px 10px; border-top: 1.5px solid var(--border); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
  text-decoration: none;
}
.sidebar-user:hover { background: var(--surface2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
  border: 1.5px solid var(--border);
}
.avatar.lg { width: 44px; height: 44px; font-size: 1rem; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .68rem; color: var(--text-3); }

/* ── LAYOUT ── */
.layout { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h); background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  gap: 16px; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--text); font-size: 20px; }

.page-content { flex: 1; padding: 28px 24px; width: 100%; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: .95rem; font-weight: 600; }
.card-subtitle { font-size: .78rem; color: var(--text-3); margin-top: 2px; }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card.highlight { background: var(--primary); border-color: var(--primary); }
.stat-card.highlight .stat-label, .stat-card.highlight .stat-value, .stat-card.highlight .stat-change { color: #fff; }
.stat-label { font-size: .72rem; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 6px; }
.stat-change { font-size: .75rem; color: var(--text-3); }
.stat-icon { font-size: 1.4rem; margin-bottom: 10px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .85rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s;
  border: 1.5px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #224a30; border-color: #224a30; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface2); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger-light); color: var(--danger); border-color: #f0c0bb; }
.btn-danger:hover { background: #f5c6c2; }
.btn-sm { padding: 6px 12px; font-size: .78rem; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: .95rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 8px; }

/* ── BADGES / PILLS ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 99px;
  font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  border: 1.5px solid transparent;
}
.badge-green { background: var(--success-light); color: var(--success); border-color: #C5D9CA; }
.badge-yellow { background: var(--warning-light); color: var(--warning); border-color: #FDE68A; }
.badge-red { background: var(--danger-light); color: var(--danger); border-color: #f0c0bb; }
.badge-blue { background: var(--info-light); color: var(--info); border-color: #BFDBFE; }
.badge-gray { background: var(--surface2); color: var(--text-2); border-color: var(--border); }
.badge-accent { background: #FBF3E0; color: #92600A; border-color: #F0D89A; }

/* Priority badges */
.prio-baixa { background: var(--info-light); color: var(--info); border-color: #BFDBFE; }
.prio-media { background: var(--warning-light); color: var(--warning); border-color: #FDE68A; }
.prio-alta { background: #FEE2E2; color: #B91C1C; border-color: #FECACA; }
.prio-urgente { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Status badges */
.status-criada { background: var(--surface2); color: var(--text-2); border-color: var(--border); }
.status-atribuida { background: var(--info-light); color: var(--info); border-color: #BFDBFE; }
.status-execucao { background: var(--warning-light); color: var(--warning); border-color: #FDE68A; }
.status-concluida { background: var(--success-light); color: var(--success); border-color: #C5D9CA; }
.status-nao-realizada { background: var(--danger-light); color: var(--danger); border-color: #f0c0bb; }
.status-reagendada { background: #FBF3E0; color: #92600A; border-color: #F0D89A; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-2); margin-bottom: 5px; letter-spacing: .01em; }
.input, select, textarea {
  width: 100%; padding: 9px 13px;
  background: var(--bg); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .875rem;
  transition: border-color .15s, background .15s;
  appearance: none; outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: var(--primary); background: var(--surface); }
textarea { resize: vertical; min-height: 90px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235C5A55' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1.5px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .85rem; }
thead th { padding: 11px 16px; text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); background: var(--bg); border-bottom: 1.5px solid var(--border); white-space: nowrap; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── SEARCH / FILTER BAR ── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap .input { padding-left: 38px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 15px; pointer-events: none; }
.filter-select { min-width: 150px; }

/* ── PAGE HEADER ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-header-left h1 { font-size: 1.4rem; font-weight: 700; }
.page-header-left p { font-size: .83rem; color: var(--text-3); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── DIVIDER ── */
.divider { height: 1.5px; background: var(--border); margin: 20px 0; }

/* ── TOGGLE ── */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-strong); border-radius: 99px;
  transition: .2s;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 16px; width: 16px;
  left: 3px; bottom: 3px; background: white; border-radius: 50%;
  transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── TABS ── */
.tabs { display: flex; border-bottom: 1.5px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 18px; font-size: .85rem; font-weight: 500; color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -1.5px;
  cursor: pointer; text-decoration: none; transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── OS CARD (mobile list) ── */
.os-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  text-decoration: none; color: inherit; display: block;
  transition: border-color .15s;
}
.os-card:hover { border-color: var(--primary-mid); }
.os-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.os-card-id { font-size: .7rem; font-weight: 700; color: var(--text-3); font-family: var(--font-mono); }
.os-card-title { font-size: .9rem; font-weight: 600; margin: 2px 0 6px; }
.os-card-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .75rem; color: var(--text-3); }

/* ── OVERLAY ── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 99;
}
.overlay.show { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .layout { margin-left: 0; }
  .hamburger { display: flex; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .page-header { flex-direction: column; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }
  table { display: none; }
  .table-mobile { display: flex; flex-direction: column; gap: 10px; }
}
@media (min-width: 769px) {
  .table-mobile { display: none; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.4rem; }
}
