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

:root {
  --primary-color: #fbbc04;
  --bg-color: #fff;
  --bg-secondary: #f1f3f4;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border-color: #e0e0e0;
  --shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 2px 6px 2px rgba(60,64,67,0.15);
  --shadow-hover: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
  --header-height: 64px;
  --sidebar-width: 260px;

  --status-pending: #e8eaed;
  --status-done: #ccff90;
  --status-paid: #a7ffeb;
  --status-postponed: #fff475;
  --status-declined: #f28b82;
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Buttons */
.btn-primary {
  background-color: var(--primary-color);
  color: var(--text-primary);
  border: none;
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.btn-primary:hover { box-shadow: var(--shadow); }

.btn-text {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}
.btn-text:hover { background-color: var(--bg-secondary); }
.btn-text.active-reorder { background-color: var(--primary-color); color: var(--text-primary); }

.icon-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  color: var(--text-secondary);
}
.icon-btn:hover { background-color: var(--bg-secondary); }
.icon-btn.active { background-color: var(--primary-color); color: var(--text-primary); }

/* Auth Screen */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #fef7e0 0%, #fff 100%);
}

.auth-container {
  background: white;
  padding: 48px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-logo .logo-text {
  font-size: 40px;
  font-weight: 700;
  color: var(--primary-color);
  background: linear-gradient(135deg, var(--primary-color), #ff6b35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.auth-logo h1 { font-size: 28px; font-weight: 400; }

.auth-form h2 {
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 24px;
  text-align: center;
}

.auth-form input {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.auth-form input:focus { border-color: var(--primary-color); }

.auth-form .btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 8px;
}

.error-message {
  background-color: #fce8e6;
  color: #c5221f;
  padding: 12px 16px;
  border-radius: 4px;
  margin-top: 16px;
  font-size: 14px;
}

/* Header */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.logo-text {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-color);
  background: linear-gradient(135deg, var(--primary-color), #ff6b35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.header-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.user-menu { position: relative; }

.dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 4px;
  box-shadow: var(--shadow);
  min-width: 200px;
  z-index: 2000;
  overflow: hidden;
}

.dropdown button {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: none;
  background: none;
  font-size: 14px;
  cursor: pointer;
}
.dropdown button:hover { background-color: var(--bg-secondary); }

.user-info {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#user-name { font-weight: 500; }
#user-email { font-size: 13px; color: var(--text-secondary); }

.unpaid-earnings {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  color: #1e8e3e;
  font-weight: 500;
}

/* Main Container */
.main-container {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--header-height);
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--bg-color);
  padding: 8px 0;
  overflow-y: auto;
  z-index: 50;
}

.nav-list { list-style: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  cursor: pointer;
  border-radius: 0 24px 24px 0;
  margin-right: 12px;
  transition: background-color 0.2s;
}
.nav-item:hover { background-color: var(--bg-secondary); }
.nav-item.active { background-color: #fef7e0; }
.nav-item.active .nav-text { font-weight: 600; }

.nav-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 8px 0;
}

/* Content */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1000px;
  margin: 0 auto 24px;
}

.content-header h2 { font-size: 20px; font-weight: 500; }

/* Pending Summary */
.pending-summary {
  max-width: 1000px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #e8f0fe;
  color: #1a73e8;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
}
.pending-summary .material-icons { font-size: 20px; }
.pending-summary b { font-size: 15px; }

/* Companies Grid */
.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
}

.company-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s;
  position: relative;
}
.company-card:hover { box-shadow: var(--shadow-hover); }
.company-card.deadline-urgent { border: 2px solid #ea4335; }
.company-card.deadline-warning { border: 2px solid #f9ab00; }
.company-card.reorder-active { cursor: grab; }
.company-card.reorder-active.dragging { opacity: 0.4; cursor: grabbing; }

.company-card .company-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding-right: 0;
}

.company-card .company-name {
  font-size: 16px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-card .company-deadline {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.company-card.deadline-urgent .company-deadline { color: #ea4335; font-weight: 500; }
.company-card.deadline-warning .company-deadline { color: #b06000; font-weight: 500; }

.company-card .company-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.company-card .company-task-stats {
  margin-top: 4px;
  justify-content: flex-start;
  gap: 12px;
  font-weight: 500;
}
.company-card .stat-done { color: #1e8e3e; }
.company-card .stat-pending { color: var(--text-secondary); }

.company-card .company-actions {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  gap: 2px;
}
.company-card:hover .company-actions { display: flex; }

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  max-width: 1000px;
  margin: 0 auto;
}
.empty-state .logo-text { font-size: 64px; opacity: 0.3; margin-bottom: 16px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
  position: relative;
  background: white;
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 24px;
}
.modal-content h3 { font-size: 18px; font-weight: 500; margin-bottom: 20px; }
.modal-content label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 12px;
}
.modal-content input,
.modal-content textarea,
.modal-content select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus { border-color: var(--primary-color); }
.modal-content textarea { resize: vertical; min-height: 60px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.modal-content-wide { max-width: 700px; }

/* Company Detail Layout */
.company-detail-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
}

.company-detail-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.company-detail-main .task-table { max-width: none; margin: 0; }

.company-detail-aside {
  width: 280px;
  flex-shrink: 0;
}

.aside-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  position: sticky;
  top: 88px;
}

.aside-card .btn-primary { width: 100%; }

.aside-title {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-top: 20px;
  margin-bottom: 8px;
}

.aside-empty { font-size: 13px; color: var(--text-secondary); }

.aside-history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}
.aside-history-item:last-child { border-bottom: none; }

.aside-history-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.aside-history-item a {
  font-size: 12px;
  color: #1a73e8;
  text-decoration: none;
  word-break: break-all;
}
.aside-history-item a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .company-detail-layout { flex-direction: column; }
  .company-detail-aside { width: 100%; }
  .aside-card { position: static; }
}

/* Collapsible task groups (Оплачено / Отказались) */
.task-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.task-group-toggle .toggle-icon {
  transition: transform 0.2s;
  font-size: 20px;
}

.task-group-toggle.expanded .toggle-icon { transform: rotate(90deg); }

.task-group-table { margin-top: 8px; }

/* Task Table */
.task-table {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.task-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.task-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  font-size: 14px;
}

.task-title-cell { vertical-align: top; }

.task-table tbody tr:last-child td { border-bottom: none; }
.task-table tbody tr:hover { background: var(--bg-secondary); }

.task-table tr[data-status="done"] { background: rgba(204, 255, 144, 0.15); }
.task-table tr[data-status="paid"] { background: rgba(167, 255, 235, 0.15); }
.task-table tr[data-status="postponed"] { background: rgba(255, 244, 117, 0.15); }
.task-table tr[data-status="declined"] { background: rgba(242, 139, 130, 0.12); }

.col-id { width: 56px; }
.col-time { width: 110px; white-space: nowrap; }
.col-deadline { width: 100px; }
.col-status { width: 130px; }
.col-actions { width: 76px; }

.task-deadline { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.task-deadline.overdue { color: #c5221f; font-weight: 500; }

.task-id-cell { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

.task-actions-cell { padding: 0 12px; }
.task-actions-inner { display: flex; align-items: center; gap: 2px; }

.task-title-cell .task-title { font-size: 14px; font-weight: 500; word-break: break-word; }
.task-title-cell .task-title.done { text-decoration: none; color: var(--text-secondary); font-weight: bold; }

.task-description {
  font-size: 13px;
  color: var(--text-primary);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-extra {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-secondary);
  border-radius: 4px;
  padding: 6px 8px;
}

.task-time { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }

.status-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--status-pending);
  cursor: pointer;
  display: inline-block;
}
.status-badge[data-status="done"] { background: var(--status-done); }
.status-badge[data-status="paid"] { background: var(--status-paid); }
.status-badge[data-status="postponed"] { background: var(--status-postponed); }
.status-badge[data-status="declined"] { background: var(--status-declined); }

.report-hint {
  max-width: 1000px;
  margin: 0 auto 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Public Report Screen */
.public-header { justify-content: flex-start; }
.public-content { padding: 100px 24px 24px; max-width: 900px; margin: 0 auto; }
.public-report-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 24px;
}
.public-report-card h1 { font-size: 22px; font-weight: 500; margin-bottom: 8px; }
.public-report-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.public-report-summary {
  display: flex;
  justify-content: flex-end;
  gap: 32px;
  margin-top: 16px;
  font-size: 15px;
}

.status-menu {
  position: absolute;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 400;
  min-width: 160px;
  overflow: hidden;
}
.status-menu button {
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  border: none;
  background: none;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-menu button:hover { background-color: var(--bg-secondary); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; }
.status-dot.pending { background: var(--status-pending); border: 1px solid var(--border-color); }
.status-dot.done { background: var(--status-done); }
.status-dot.paid { background: var(--status-paid); }
.status-dot.postponed { background: var(--status-postponed); }
.status-dot.declined { background: var(--status-declined); }

/* Add task inline form */
.add-task-bar {
  max-width: 1000px;
  margin: 0 auto 20px;
}

/* Report */
.report-summary {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  max-width: 1000px;
  margin: 0 auto 20px;
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}
.report-stat { display: flex; flex-direction: column; gap: 4px; }
.report-stat .label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.report-stat .value { font-size: 22px; font-weight: 500; }

.report-filters {
  max-width: 1000px;
  margin: 0 auto 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.report-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #323232;
  color: white;
  padding: 12px 24px;
  border-radius: 4px;
  z-index: 500;
  box-shadow: var(--shadow);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 72px; }
  .sidebar .nav-text { display: none; }
  .content { margin-left: 72px; }
  .header-title { display: none; }
}
