* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: #f0f2f5; color: #1a1a2e; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 220px; background: #1a1a2e; color: white; padding: 24px 0; position: fixed; height: 100vh; }
.logo { font-size: 22px; font-weight: 700; padding: 0 24px 24px; border-bottom: 1px solid #2d2d4e; color: #4fc3f7; }
nav { margin-top: 16px; }
.nav-item { display: block; padding: 12px 24px; color: #aaa; text-decoration: none; font-size: 14px; transition: all 0.2s; }
.nav-item:hover, .nav-item.active { background: #2d2d4e; color: white; border-left: 3px solid #4fc3f7; }

/* Main */
.main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; }
.page-content { padding: 32px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* Page Header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 26px; font-weight: 700; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.card-label { font-size: 12px; text-transform: uppercase; color: #888; letter-spacing: 1px; }
.card-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.card-value.green { color: #2e7d32; }
.card-value.red { color: #c62828; }
.card-value.blue { color: #1565c0; }

/* Table */
.table-wrap { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 12px; background: #f5f7fa; font-size: 12px; text-transform: uppercase; color: #666; letter-spacing: 0.5px; }
td { padding: 12px; border-bottom: 1px solid #f0f0f0; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-red { background: #ffebee; color: #c62828; }
.badge-blue { background: #e3f2fd; color: #1565c0; }
.badge-yellow { background: #fffde7; color: #f57f17; }
.badge-gray { background: #f5f5f5; color: #666; }

/* Buttons */
.btn { padding: 10px 18px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; transition: all 0.2s; }
.btn-primary { background: #1565c0; color: white; }
.btn-primary:hover { background: #0d47a1; }
.btn-success { background: #2e7d32; color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: #c62828; color: white; font-size: 12px; padding: 6px 12px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-outline { background: white; border: 1px solid #ddd; color: #333; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #444; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; background: white;
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.hidden { display: none; }
.modal { background: white; border-radius: 12px; width: 90%; max-width: 580px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid #eee; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #888; }
#modal-body { padding: 24px; }

/* Invoice items */
.item-row { display: grid; grid-template-columns: 3fr 1fr 1fr auto; gap: 10px; align-items: center; margin-bottom: 8px; }
.item-row input { padding: 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }

/* Report section */
.report-section { background: white; border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.report-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid #f0f0f0; }
.report-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f9f9f9; font-size: 14px; }
.report-total { display: flex; justify-content: space-between; padding: 12px 0; font-weight: 700; font-size: 16px; border-top: 2px solid #eee; margin-top: 8px; }

/* Filters */
.filters { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; background: white; }

.empty { text-align: center; padding: 40px; color: #aaa; font-size: 15px; }

/* Company Switcher */
.company-switcher { padding: 16px; border-bottom: 1px solid #2d2d4e; position: relative; }
.company-name { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 10px 12px; border-radius: 8px; background: #2d2d4e; color: white; font-weight: 600; font-size: 13px; }
.company-name:hover { background: #3d3d6e; }
.chevron { font-size: 12px; color: #aaa; }
.company-menu { position: absolute; top: 100%; left: 16px; right: 16px; background: white; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.3); z-index: 999; overflow: hidden; margin-top: 4px; }
.company-menu.hidden { display: none; }
.company-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; font-size: 13px; color: #333; border-bottom: 1px solid #f0f0f0; }
.company-item:hover { background: #f5f7fa; }
.company-item.active { background: #e3f2fd; color: #1565c0; font-weight: 600; }
.company-item:last-child { border-bottom: none; }
.company-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.company-add { padding: 10px 16px; font-size: 13px; color: #1565c0; cursor: pointer; text-align: center; font-weight: 600; }
.company-add:hover { background: #f0f8ff; }

/* Sidebar Footer / User Info */
.sidebar-footer { padding: 16px; border-top: 1px solid #2d2d4e; margin-top: auto; position: absolute; bottom: 0; width: 220px; display: none; }
.user-info { font-size: 12px; color: #aaa; margin-bottom: 8px; line-height: 1.4; }
.user-info strong { color: white; display: block; font-size: 13px; }
.btn-logout { width: 100%; padding: 8px; background: transparent; border: 1px solid #444; color: #aaa; border-radius: 6px; cursor: pointer; font-size: 12px; transition: all 0.2s; }
.btn-logout:hover { background: #c62828; border-color: #c62828; color: white; }
.sidebar { padding-bottom: 100px; }

/* Role badges */
.badge-superadmin { background: #f3e5f5; color: #6a1b9a; }
.badge-admin { background: #e3f2fd; color: #1565c0; }
.badge-viewer { background: #f5f5f5; color: #666; }


/* Top user bar */
.top-bar {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 32px;
  background: white;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.top-bar.visible { display: flex; }
.top-bar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #555;
}
.top-bar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1a1a2e;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.top-bar-name { font-weight: 600; color: #1a1a2e; }
.top-bar-role {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: #e3f2fd;
  color: #1565c0;
  font-weight: 600;
}
.top-bar-time { font-size: 12px; color: #aaa; margin-left: 4px; }

/* Top bar logout button */
.top-bar-logout {
  padding: 7px 16px;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 8px;
  color: #666;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 8px;
}
.top-bar-logout:hover {
  background: #c62828;
  border-color: #c62828;
  color: white;
}
