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

:root {
  --header-bg: #f5e6d3;
  --group-bg: #f0dcc8;
  --yellow-row: #ffff00;
  --border: #333;
  --tab-active: #4a7c59;
  --tab-bg: #e8e8e8;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  background: #f4f4f4;
  color: #111;
}

.hidden {
  display: none !important;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #e8f0ea 0%, #f4f4f4 50%);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 22px;
}

.login-sub {
  text-align: center;
  color: #666;
  margin: 0 0 24px;
  font-size: 13px;
}

.login-label {
  display: block;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 4px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid #aaa;
  border-radius: 6px;
  font-size: 14px;
}

.login-card input:focus {
  outline: 2px solid var(--tab-active);
  border-color: var(--tab-active);
}

.login-btn {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  margin-top: 4px;
}

.login-error {
  color: #c62828;
  font-size: 12px;
  margin: 0 0 10px;
  text-align: center;
}

/* Workbook picker (step 1) */
.workbook-picker {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #e8f0ea 0%, #f4f4f4 50%);
}

.picker-inner {
  max-width: 720px;
  width: 100%;
}

.picker-inner h1 {
  text-align: center;
  font-size: 22px;
  margin: 0 0 8px;
}

.picker-sub {
  text-align: center;
  color: #555;
  margin: 0 0 28px;
}

.workbook-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.workbook-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 20px;
  border: 2px solid #ccc;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.workbook-card:hover {
  border-color: var(--tab-active);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.workbook-card-icon {
  font-size: 28px;
}

.workbook-card-title {
  font-size: 14px;
  font-weight: bold;
  line-height: 1.3;
}

.workbook-card-meta {
  font-size: 12px;
  color: #666;
}

.picker-empty {
  text-align: center;
  color: #888;
}

/* Main app (step 2) */
.app {
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 52px;
}

.workbook-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #2c3e50;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 200;
}

.btn-back {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.1);
}

.active-workbook-name {
  font-size: 13px;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.user-name {
  font-size: 12px;
  color: #ccc;
  white-space: nowrap;
}

.btn-logout {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
}

.doc-header {
  background: #fff;
  border-bottom: 2px solid var(--border);
  padding: 12px 16px 8px;
}

.logo {
  width: 48px;
  height: 48px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  float: left;
  margin-right: 12px;
}

.doc-title {
  text-align: center;
  font-size: 18px;
  margin: 0 60px 10px;
  letter-spacing: 0.5px;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  clear: both;
  font-size: 12px;
}

.meta-table th,
.meta-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
}

.meta-table th {
  background: #fff;
  font-weight: bold;
  text-align: left;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #ccc;
  flex-wrap: wrap;
}

.btn {
  padding: 6px 14px;
  border: 1px solid #888;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.btn:hover {
  background: #eee;
}

.btn-primary {
  background: var(--tab-active);
  color: #fff;
  border-color: var(--tab-active);
}

.btn-primary:hover {
  background: #3d6649;
}

.btn-danger {
  color: #c00;
  border-color: #c00;
  padding: 2px 8px;
  font-size: 11px;
}

.status-msg {
  margin-left: auto;
  color: #2e7d32;
  font-size: 12px;
}

.status-msg.error {
  color: #c62828;
}

.table-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
  margin: 0;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.log-table th,
.log-table td {
  border: 1px solid #999;
  padding: 0;
  vertical-align: middle;
}

.log-table thead th {
  background: var(--header-bg);
  font-weight: bold;
  text-align: center;
  padding: 6px 4px;
  font-size: 11px;
  white-space: nowrap;
}

.log-table thead tr.group-row th {
  background: var(--group-bg);
  font-size: 10px;
  padding: 3px 4px;
}

.log-table .col-sr {
  width: 40px;
  text-align: center;
  background: #fafafa;
  font-weight: bold;
  padding: 4px;
}

.log-table input,
.log-table textarea {
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 4px;
  font: inherit;
  font-size: 12px;
  resize: vertical;
  min-height: 28px;
}

.log-table input:focus,
.log-table textarea:focus {
  outline: 2px solid var(--tab-active);
  background: var(--yellow-row);
}

.log-table tr:hover td {
  background: #fffde7;
}

.log-table .actions {
  width: 60px;
  text-align: center;
  padding: 2px;
}

.sheet-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  overflow-x: auto;
  background: var(--tab-bg);
  border-top: 2px solid #999;
  z-index: 100;
  -webkit-overflow-scrolling: touch;
}

.sheet-tab {
  flex-shrink: 0;
  padding: 10px 16px;
  border: none;
  border-right: 1px solid #bbb;
  background: var(--tab-bg);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.sheet-tab:hover {
  background: #ddd;
}

.sheet-tab.active {
  background: var(--tab-active);
  color: #fff;
  font-weight: bold;
}

@media (max-width: 768px) {
  .doc-title {
    font-size: 14px;
    margin: 0 0 8px;
  }

  .logo {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .meta-table {
    font-size: 10px;
  }

  .sheet-tab {
    padding: 10px 12px;
    font-size: 11px;
  }
}
