:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e6eb;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --unread: #eef2ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.content { padding: 20px; flex: 1; overflow: auto; }

/* Brand */
.brand { font-weight: 700; font-size: 18px; color: var(--accent); margin-bottom: 8px; }
.brand span { color: var(--text); }

/* Buttons */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 14px; line-height: 1;
}
.btn:hover { background: #f0f1f4; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #f3c0c0; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

/* Sidebar nav */
.navlink {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 8px; color: var(--text);
}
.navlink:hover { background: #f0f1f4; text-decoration: none; }
.navlink.active { background: var(--unread); color: var(--accent-dark); font-weight: 600; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 8px 4px; }

/* Forms */
input[type=text], input[type=password], input[type=email], input[type=number],
textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
textarea { resize: vertical; min-height: 220px; }
label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13px; }
.field-help { color: var(--muted); font-size: 12px; }

/* Cards / panels */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin-top: 0; }

/* Message list */
.msglist { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.msgrow {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.msgrow:last-child { border-bottom: none; }
.msgrow:hover { background: #fafbfc; }
.msgrow.unread { background: var(--unread); }
.msgrow .from { width: 200px; flex-shrink: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgrow.read .from { font-weight: 400; }
.msgrow .subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgrow .subject .preview { color: var(--muted); font-weight: 400; }
.msgrow .date { width: 90px; text-align: right; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.msgrow .star { color: #d1d5db; }
.msgrow .star.on { color: var(--warning); }

/* Tables */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.grid th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* Flash */
.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid; }
.flash.success { background: #ecfdf3; color: #027a48; border-color: #abefc6; }
.flash.danger  { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.flash.warning { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.flash.info    { background: #eff8ff; color: #175cd3; border-color: #b2ddff; }

/* Message view */
.msgview .head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.msgview .subject { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.msgview .meta { color: var(--muted); }
.msgbody { line-height: 1.55; }
.msgbody img { max-width: 100%; height: auto; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.spacer { flex: 1; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.stat { display: flex; gap: 18px; }
.stat .card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; flex: 1; }
.stat .card .n { font-size: 28px; font-weight: 700; }
.stat .card .l { color: var(--muted); font-size: 13px; }
.quota { font-size: 12px; color: var(--muted); margin-top: auto; padding-top: 12px; }
.quota .bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.quota .bar > div { height: 100%; background: var(--accent); }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cal-head { background: var(--panel); padding: 8px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-cell { background: var(--panel); min-height: 96px; padding: 4px 6px; display: flex; flex-direction: column; gap: 3px; }
.cal-cell.other-month { background: #fafbfc; }
.cal-cell.other-month .cal-daynum a { color: #c0c4cc; }
.cal-cell.today { background: var(--unread); }
.cal-daynum { font-size: 12px; text-align: right; }
.cal-daynum a { color: var(--text); }
.cal-event { display: block; font-size: 11px; color: #fff; padding: 2px 6px; border-radius: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event:hover { text-decoration: none; opacity: .9; }

/* Chat */
.chat { display: flex; gap: 16px; height: calc(100vh - 140px); }
.chat .convos { width: 240px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: auto; }
.chat .convo { display: block; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.chat .convo:hover, .chat .convo.active { background: var(--unread); text-decoration: none; }
.chat .convo .badge { float: right; }
.chat .thread { flex: 1; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.chat .msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 70%; padding: 8px 12px; border-radius: 12px; font-size: 14px; }
.bubble.in { background: #f0f1f4; align-self: flex-start; }
.bubble.out { background: var(--accent); color: #fff; align-self: flex-end; }
.bubble .when { display: block; font-size: 10px; opacity: .7; margin-top: 2px; }
.chat .composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat .composer input { flex: 1; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 20, 35, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 1000; overflow: auto; }
.modal-overlay[hidden] { display: none; }
.modal-card { background: var(--panel); border-radius: 14px; width: 100%; max-width: 540px; padding: 24px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-x { position: absolute; top: 12px; right: 14px; border: none; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-x:hover { color: var(--text); }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }
.inline { display: inline; }

/* ============================================================
   Tema estilo Gmail (webmail) — sobrescreve componentes acima
   ============================================================ */
body { font-family: "Google Sans", Roboto, Arial, "Segoe UI", sans-serif; background: #f6f8fc; }
:root { --g-blue:#1a73e8; --g-red:#d93025; --g-ink:#202124; --g-grey:#5f6368; --g-line:#e8eaed; }

.sidebar { background: #f6f8fc; border-right: none; padding: 12px 8px; }
.topbar { background: #f6f8fc; border-bottom: 1px solid var(--g-line); }
.content { background: #fff; border-top-left-radius: 16px; margin: 0; }
.main { background: #f6f8fc; }

/* Botão Escrever (Gmail) */
.compose-btn {
  display: inline-flex; align-items: center; gap: 10px; align-self: flex-start;
  padding: 14px 22px 14px 16px; margin: 4px 4px 14px; border-radius: 16px;
  background: #c2e7ff; color: #001d35; font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 3px rgba(60,64,67,.3); transition: box-shadow .2s, background .2s;
}
.compose-btn:hover { background: #b3dcff; box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px rgba(60,64,67,.15); text-decoration: none; }
.compose-btn .pencil { font-size: 16px; }

/* Navegação de pastas estilo Gmail (pílula à direita) */
.navlink { border-radius: 0 16px 16px 0; padding: 7px 12px 7px 20px; color: var(--g-ink); font-size: 14px; margin-right: 6px; }
.navlink:hover { background: #e9eaed; }
.navlink.active { background: #d3e3fd; color: #041e49; font-weight: 600; }
.navlink.active .badge, .badge { background: transparent; color: var(--g-grey); font-weight: 600; padding: 0; }
.navlink.active .badge { color: #041e49; }
.section-label { color: var(--g-grey); margin: 16px 8px 4px 20px; }

/* Barra de busca arredondada */
.searchbar { flex: 1; max-width: 720px; display: flex; align-items: center; gap: 10px;
  background: #eaf1fb; border-radius: 26px; padding: 0 16px; height: 46px; }
.searchbar:focus-within { background: #fff; box-shadow: 0 1px 6px rgba(32,33,36,.18); }
.searchbar input { border: none; background: transparent; height: 44px; font-size: 15px; }
.searchbar input:focus { outline: none; }
.search-ico { color: var(--g-grey); }

/* Lista de mensagens estilo Gmail */
.msglist { border: none; border-radius: 0; background: #fff; }
.msgrow { padding: 0 16px; height: 44px; gap: 14px; border-bottom: 1px solid #f1f3f4; position: relative; }
.msgrow:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60,64,67,.3); z-index: 1; }
.msgrow.unread { background: #fff; }
.msgrow.read { background: #f2f6fc; }
.msgrow .star { color: #dadce0; font-size: 18px; }
.msgrow .star.on { color: #f4b400; }
.msgrow .from { width: 220px; color: var(--g-ink); font-size: 14px; }
.msgrow.unread .from, .msgrow.unread .subject { font-weight: 700; color: #202124; }
.msgrow.read .from, .msgrow.read .subject { font-weight: 400; color: #5f6368; }
.msgrow .subject .preview { color: var(--g-grey); font-weight: 400; }
.msgrow .date { width: 70px; font-size: 12px; color: var(--g-grey); }
.msgrow.unread .date { font-weight: 700; color: #202124; }

/* Visualização de mensagem */
.msgview { border: none; box-shadow: none; padding: 8px 0; }
.msgview .subject { font-size: 22px; font-weight: 400; color: var(--g-ink); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--g-blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; flex-shrink: 0; }

/* Botões mais arredondados no webmail */
.content .btn { border-radius: 18px; }
.content .btn-primary { background: var(--g-blue); border-color: var(--g-blue); }

/* Ações no hover da linha (estilo Gmail) */
.msgrow .star { border: none; background: none; cursor: pointer; font-size: 16px; padding: 0; }
.msgrow .clip { font-size: 13px; }
.msgrow-end { width: 90px; display: flex; align-items: center; justify-content: flex-end; flex-shrink: 0; }
.row-actions { display: none; gap: 2px; }
.rowact { border: none; background: none; cursor: pointer; font-size: 15px; padding: 2px 4px; border-radius: 50%; line-height: 1; }
.rowact:hover { background: #e9eaed; }
.msgrow:hover .date { display: none; }
.msgrow:hover .row-actions { display: flex; }

/* Menu de opções da linha */
.msglist { overflow: visible; }
.menu-wrap { position: relative; }
.menu-pop { display: none; position: absolute; right: 0; top: 26px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,.18);
  z-index: 30; min-width: 190px; padding: 6px 0; max-height: 300px; overflow: auto; }
.menu-pop.open { display: block; }
.menu-pop form button { display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--text); border-radius: 0; }
.menu-pop form button:hover { background: #f1f3f4; }
.menu-sep { padding: 8px 14px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; }

/* Barra de seleção múltipla */
.bulkbar { display: flex; align-items: center; gap: 12px; padding: 6px 8px; margin-bottom: 6px; }
.bulkbar input[type=checkbox] { width: 16px; height: 16px; }
.bulk-actions { display: none; gap: 6px; align-items: center; flex-wrap: wrap; }
.msgrow .rowchk { width: 16px; height: 16px; flex-shrink: 0; cursor: default; }
