:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #202124;
  background: #ffffff;
  font-size: 13px;
  --border: #dadce0;
  --muted: #5f6368;
  --green: #188038;
  --blue: #1a73e8;
  --selection: rgba(26, 115, 232, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app { height: 100vh; display: flex; flex-direction: column; }

.login { min-height: 100vh; display: grid; place-items: center; background: #f8f9fa; }
.login-card { width: min(360px, calc(100vw - 32px)); padding: 36px; background: white; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 4px 18px rgba(60,64,67,.12); }
.login-card h1 { margin: 18px 0 8px; font-size: 24px; font-weight: 500; }
.login-card p { color: var(--muted); margin: 0 0 26px; }
.login-card label { display: block; margin-bottom: 6px; font-weight: 600; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 5px; margin-bottom: 16px; }
.primary { width: 100%; padding: 11px; border: 0; border-radius: 5px; color: white; background: var(--blue); }
.brand-mark { display: inline-flex; align-items: center; background: transparent; }
.brand-mark img { display: block; width: 180px; height: auto; }
.brand-mark.small img { width: 150px; }
.error { min-height: 20px; margin-top: 12px; color: #d93025; }

.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 8px 18px; gap: 16px; }
.document-title { display: flex; align-items: center; gap: 12px; }
.document-title h1 { font-size: 18px; font-weight: 400; margin: 0 0 3px; }
.save-status { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.connection-status { color: var(--muted); font-size: 12px; }
.connection-status.online { color: var(--green); }
.connection-status.offline { color: #d93025; }
.text-button { border: 0; background: transparent; color: var(--blue); padding: 7px; }

.toolbar { display: flex; align-items: center; gap: 3px; min-height: 42px; margin: 0 14px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: #f8f9fa; overflow-x: auto; }
.toolbar button { min-width: 29px; height: 29px; padding: 3px 7px; border: 0; border-radius: 4px; background: transparent; color: #3c4043; }
.toolbar button:hover, .toolbar button.active { background: #e8eaed; }
.separator { width: 1px; height: 22px; background: var(--border); margin: 0 5px; flex: none; }
.color-control { display: flex; align-items: center; gap: 4px; white-space: nowrap; color: #3c4043; }
.color-control input { width: 25px; height: 25px; padding: 0; border: 1px solid var(--border); background: transparent; }
#numberFormat { height: 29px; border: 1px solid var(--border); border-radius: 4px; background: white; color: #3c4043; }

.formula-bar { display: flex; align-items: center; height: 34px; margin-top: 7px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
#nameBox { width: 92px; height: 100%; padding: 0 9px; border: 0; border-right: 1px solid var(--border); text-align: center; background: white; }
.fx { width: 38px; text-align: center; color: var(--muted); font-style: italic; }
#formulaInput { flex: 1; height: 100%; border: 0; outline: 0; padding: 0 8px; font-family: Arial, Helvetica, sans-serif; }

.grid-viewport { flex: 1; overflow: auto; position: relative; background: white; }
.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; user-select: none; }
.grid th, .grid td { border-right: 1px solid #e0e0e0; border-bottom: 1px solid #e0e0e0; height: 25px; min-height: 25px; padding: 0; }
.grid th { position: sticky; background: #f8f9fa; color: #5f6368; font-weight: 400; text-align: center; z-index: 2; }
.grid thead th { top: 0; height: 27px; border-top: 1px solid #e0e0e0; }
.grid tbody th { left: 0; width: 46px; min-width: 46px; z-index: 1; }
.grid .corner { left: 0; z-index: 3; width: 46px; min-width: 46px; }
.grid th.col-header { min-width: 110px; width: 110px; }
.grid td { background: white; overflow: hidden; white-space: pre; text-overflow: ellipsis; vertical-align: middle; position: relative; }
.grid td .cell-content { display: block; overflow: hidden; text-overflow: ellipsis; padding: 3px 5px; line-height: 19px; }
.grid td.numeric .cell-content { text-align: right; }
.grid td.selected-range { background-color: var(--selection) !important; }
.grid td.active-cell { outline: 2px solid var(--blue); outline-offset: -2px; }
.grid td.editing { padding: 0; outline: 2px solid var(--blue); outline-offset: -2px; }
.grid td.editing input { width: 100%; height: 100%; min-height: 23px; border: 0; outline: 0; padding: 2px 4px; background: white; }
.grid th.selected-header { background: #d3e3fd; color: #174ea6; }

.sheet-footer { min-height: 40px; display: flex; align-items: stretch; justify-content: space-between; border-top: 1px solid var(--border); }
.sheet-tabs { display: flex; align-items: stretch; overflow-x: auto; }
.sheet-tabs button { border: 0; border-right: 1px solid var(--border); background: white; padding: 0 20px; color: #3c4043; white-space: nowrap; }
.sheet-tabs button.active { color: var(--green); font-weight: 700; box-shadow: inset 0 -3px 0 var(--green); background: #e6f4ea; }
.grid-size-actions { display: flex; align-items: center; }
.grid-size-actions button { border: 0; background: transparent; color: var(--muted); padding: 0 10px; }
.toast { position: fixed; left: 50%; bottom: 54px; transform: translateX(-50%); background: #202124; color: white; border-radius: 5px; padding: 9px 15px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.toast.visible { opacity: 1; }

@media (max-width: 760px) {
  .top-actions .connection-status { display: none; }
  .toolbar { margin: 0 6px; }
  .grid-size-actions { display: none; }
  .sheet-tabs button { padding: 0 12px; }
}
